P: n/a

How do i evaulate a mathematical expression that is entered in a text
field.
Ex:
Text Fields:
Xo=23
X1= 250
Expression: y = Xoe^(x1+Xo)cos(X0+X1)+23Xo
How do i manage that?
tx  
Share this Question
P: n/a

On Aug 31, 10:29*am, serave <ramirez.sebast...@gmail.comwrote:
How do i evaulate a mathematical expression that is entered in a text
field.
Ex:
Text Fields:
Xo=23
X1= 250
Expression: y = Xoe^(x1+Xo)cos(X0+X1)+23Xo
How do i manage that?
You have X0, x1, Xo, and X1 on the right side of the equation but
define only Xo and X1. Thus the equation can not be solved as a
numerical value for y unless you define one other value with some
numerical value. Perhaps there is a typo in the equation? If you mean
to simplify the equation as written, that is a problem in algebra.
If you define another value or correct a possible typo, either the
math functions of php or Javascript can be used to solve the
equation(the value of y for perhaps a value of x1 ?) because the
simple math functions, exponentials, and cos are all contained in both
languages.  
P: n/a

On 31 aug, 17:29, serave <ramirez.sebast...@gmail.comwrote:
Xo=23
X1= 250
Expression: y = Xoe^(x1+Xo)cos(X0+X1)+23Xo
To do this in PHP, you first parse the expression to convert it from a
string to a structure. You have to make a parser to do this. Next, you
compute the result.
It is far from trivial to do this in PHP. A better approach may be to
use something like bc ( http://www.gnu.org/software/bc/) or another
program to evaluate the expression for you.  
P: n/a

Do you know if there is something already wrote, maybe in javascript
or something caise i will take lots of lines to do it again. And there
might be somebody that has already wrote that?  
P: n/a

On Aug 31, 1:03*pm, cwdjrxyz <spamtr...@cwdjr.infowrote:
On Aug 31, 10:29*am, serave <ramirez.sebast...@gmail.comwrote:
How do i evaulate a mathematical expression that is entered in a text
field.
Ex:
Text Fields:
Xo=23
X1= 250
Expression: y = Xoe^(x1+Xo)cos(X0+X1)+23Xo
How do i manage that?
You have X0, x1, Xo, and X1 on the right side of the equation but
define only Xo and X1. Thus the equation can not be solved as a
numerical value for y unless you define one other value with some
numerical value. Perhaps there is a typo in the equation? If you mean
to simplify the equation as written, that is a problem in algebra.
If you define another value or correct a possible typo, either the
math functions of php or Javascript can be used to solve the
equation(the value of y for perhaps a value of x1 ?) *because the
simple math functions, exponentials, and cos are all contained in both
languages.
You will find how to use the math functions in Javascript and PHP in
most more complete books published on these subjects in the last
several years. Reading several of the examples given in most of these
books will likely help.
To show how math functions are used on a real web page, I have
examples using both Javascript and PHP.
For the Javascript example, view the source code of http://www.cwdjr.net/math/cylinderAbsorption.html .
For the PHP code for http://www.cwdjr.net/calendar2/perpetual_calendar.php
view the text file: http://www.cwdjr.net/calendar2/perpetual_calendar.txt .  
P: n/a

My problem is not the equation, or simplifing it. i just need to
evaluate what evere equation is given by the user. How will no write
it as php or javsacsript will demant it. I need to transform the
equation to a language like php or javascript or whatevere i can use
web. I'm looking for some info like that. Maybe a predifine function
that does that job.  
P: n/a

serave wrote:
Do you know if there is something already wrote, maybe in javascript
or something caise i will take lots of lines to do it again. And there
might be somebody that has already wrote that?
It won't help much to have something already written in javascript 
unless you want to try to convert it to PHP yourself.
But even if you do, I don't know of anything which wouldn't be
proprietary. And as Sjoerd said, this is not trivial. It can be done,
but you have a lot of work ahead of you.
I did something like this many years ago in C. I used a structure with
three parameters  the two values and the operation to be performed.
The operation was simple  but if a value was computed, I pointed to the
structure whose results was the value (via a UNION in the structure) to
be used.
However, I was not dealing with variables, etc. All I need to do was
give the results for an expression. It was orders of magnitude simpler
than what you want to do. But it was still difficult to get everything
sorted out and computed properly.

==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================  
P: n/a

On 31 ago, 15:32, Jerry Stuckle <jstuck...@attglobal.netwrote:
serave wrote:
Do you know if there is something already wrote, maybe in javascript
or something caise i will take lots of lines to do it again. And there
might be somebody that has already wrote that?
It won't help much to have something already written in javascript 
unless you want to try to convert it to PHP yourself.
But even if you do, I don't know of anything which wouldn't be
proprietary. And as Sjoerd said, this is not trivial. *It can be done,
but you have a lot of work ahead of you.
I did something like this many years ago in C. *I used a structure with
three parameters  the two values and the operation to be performed.
The operation was simple  but if a value was computed, I pointed to the
structure whose results was the value (via a UNION in the structure) to
be used.
However, I was not dealing with variables, etc. *All I need to do was
give the results for an expression. It was orders of magnitude simpler
than what you want to do. *But it was still difficult to get everything
sorted out and computed properly.

==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
tx for you information. But actually i'm going to work with php, but
if i can get something that evaluates(give the result) the function
writen by an end user, i can put it in variable and from then on i
will start my job in php  
P: n/a

serave wrote:
On 31 ago, 15:32, Jerry Stuckle <jstuck...@attglobal.netwrote:
>serave wrote:
>>Do you know if there is something already wrote, maybe in javascript or something caise i will take lots of lines to do it again. And there might be somebody that has already wrote that?
It won't help much to have something already written in javascript  unless you want to try to convert it to PHP yourself.
But even if you do, I don't know of anything which wouldn't be proprietary. And as Sjoerd said, this is not trivial. It can be done, but you have a lot of work ahead of you.
I did something like this many years ago in C. I used a structure with three parameters  the two values and the operation to be performed. The operation was simple  but if a value was computed, I pointed to the structure whose results was the value (via a UNION in the structure) to be used.
However, I was not dealing with variables, etc. All I need to do was give the results for an expression. It was orders of magnitude simpler than what you want to do. But it was still difficult to get everything sorted out and computed properly.
tx for you information. But actually i'm going to work with php, but
if i can get something that evaluates(give the result) the function
writen by an end user, i can put it in variable and from then on i
will start my job in php
Sjoerd's is probably the best suggestion. But even so, you're looking
at lots of work.

==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================  
P: n/a

On Aug 31, 3:27*pm, serave <ramirez.sebast...@gmail.comwrote:
My problem is not the equation, or simplifing it. i just need to
evaluate what evere equation is given by the user. How will no write
it as php or javsacsript will demant it. I need to transform the
equation to a language like php or javascript or whatevere i can use
web. I'm looking for some info like that. Maybe a predifine function
that does that job.
Thanks for the additional information. If I understand you correctly
now, you want a program into which you can type a mathematical
equation much as it would appear in a math text. Then you want the
program to take that input, convert it into some code to solve the
equation and perhaps tabulate the results in tables, plots etc.
If the above is so, there long have been programs designed to do this.
They are used by people in math, engineering, the sciences etc. Such
programs are extremely complex, and if this is what you have in mind I
would suggest that you not waste your time on such a project. I am not
sure that any one person, no matter how skilled, could come up with
such a program that would be anywhere close to the quality of what is
available. Some such programs can be put up on a server so that input
can be from the web. However such programs are very expensive, for
good reason. Even so, input has to follow strict rules for the program
to work properly. The program must have very complex error detection
features, for there is no telling what someone may type in. Such a
program would most likely be written mostly in C++ or something of
that sort.  
P: n/a

On 31 ago, 17:44, cwdjrxyz <spamtr...@cwdjr.infowrote:
On Aug 31, 3:27*pm, serave <ramirez.sebast...@gmail.comwrote:
My problem is not the equation, or simplifing it. i just need to
evaluate what evere equation is given by the user. How will no write
it as php or javsacsript will demant it. I need to transform the
equation to a language like php or javascript or whatevere i can use
web. I'm looking for some info like that. Maybe a predifine function
that does that job.
Thanks for the additional information. If I understand you correctly
now, you want a program into which you can type a mathematical
equation much as it would appear in a math text. Then you want the
program to take that input, convert it into some code to solve the
equation and perhaps tabulate the results in tables, plots etc.
If the above is so, there long have been programs designed to do this.
They are used by people in math, engineering, the sciences etc. Such
programs are extremely complex, and if this is what you have in mind I
would suggest that you not waste your time on such a project. I am not
sure that any one person, no matter how skilled, could come up with
such a program that would be anywhere close to the quality of what is
available. Some such programs can be put up on a server so that input
can be from the web. However such programs are very expensive, for
good reason. Even so, input has to follow strict rules for the program
to work properly. The program must have very complex error detection
features, for there is no telling what someone may type in. Such a
program would most likely be written mostly in C++ or something of
that sort.
tx a lot what you are saying is exactly what im looking for,but
hopefully free, or just a library to get the cuntion i just need it to
dosome additional work. i need to program some nnumerical methods, but
the entries must be given from and end user so i need the equation
parser  
P: n/a

serave wrote:
On 31 ago, 17:44, cwdjrxyz <spamtr...@cwdjr.infowrote:
>On Aug 31, 3:27 pm, serave <ramirez.sebast...@gmail.comwrote:
>>My problem is not the equation, or simplifing it. i just need to evaluate what evere equation is given by the user. How will no write it as php or javsacsript will demant it. I need to transform the equation to a language like php or javascript or whatevere i can use web. I'm looking for some info like that. Maybe a predifine function that does that job.
Thanks for the additional information. If I understand you correctly now, you want a program into which you can type a mathematical equation much as it would appear in a math text. Then you want the program to take that input, convert it into some code to solve the equation and perhaps tabulate the results in tables, plots etc.
If the above is so, there long have been programs designed to do this. They are used by people in math, engineering, the sciences etc. Such programs are extremely complex, and if this is what you have in mind I would suggest that you not waste your time on such a project. I am not sure that any one person, no matter how skilled, could come up with such a program that would be anywhere close to the quality of what is available. Some such programs can be put up on a server so that input can be from the web. However such programs are very expensive, for good reason. Even so, input has to follow strict rules for the program to work properly. The program must have very complex error detection features, for there is no telling what someone may type in. Such a program would most likely be written mostly in C++ or something of that sort.
tx a lot what you are saying is exactly what im looking for,but
hopefully free, or just a library to get the cuntion i just need it to
dosome additional work. i need to program some nnumerical methods, but
the entries must be given from and end user so i need the equation
parser
The point is  you are not going to find something like that for free.
They'll probably cost you tens of thousands of dollars.
As we've been trying to tell you. Such a script is not trivial. It
takes a lot of work to develop. And people don't give all of that work
away for free. They need to live, also.
It's also too specialized for the open source community. You'll find
very little interest there.
Probably the best free you'll find will be what Sjoerd recommended.

==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================  
P: n/a

serave wrote:
On 31 ago, 15:32, Jerry Stuckle <jstuck...@attglobal.netwrote:
>serave wrote:
>>Do you know if there is something already wrote, maybe in javascript or something caise i will take lots of lines to do it again. And there might be somebody that has already wrote that?
It won't help much to have something already written in javascript  unless you want to try to convert it to PHP yourself.
But even if you do, I don't know of anything which wouldn't be proprietary. And as Sjoerd said, this is not trivial. It can be done, but you have a lot of work ahead of you.
I did something like this many years ago in C. I used a structure with three parameters  the two values and the operation to be performed. The operation was simple  but if a value was computed, I pointed to the structure whose results was the value (via a UNION in the structure) to be used.
However, I was not dealing with variables, etc. All I need to do was give the results for an expression. It was orders of magnitude simpler than what you want to do. But it was still difficult to get everything sorted out and computed properly.
tx for you information. But actually i'm going to work with php, but
if i can get something that evaluates(give the result) the function
writen by an end user, i can put it in variable and from then on i
will start my job in php
Just as a precautionary note, if you actually try to write some sort
of equation parser, you may be tempted to use eval(). *DON'T*. User
input mixed with eval() is perhaps the most dangerous exploit you can
expose.
If you do try to use Sjoerd's suggestion, do not forget to look up
PHP's command line sanitizing functions. For example, when passing
arguments, use escapeshellarg(). It's used for escaping *individual*
arguments.
Be extremely careful when exposing user input to the shell.

Curtis  
P: n/a

On Aug 31, 5:29*pm, serave <ramirez.sebast...@gmail.comwrote:
How do i evaulate a mathematical expression that is entered in a text
field.
What exactly do you want? Why do you want to evaluate mathematical
expressions? Do you simply want the numerical value of y?  
P: n/a

On 1 sep, 02:50, Sjoerd <sjoer...@gmail.comwrote:
On Aug 31, 5:29*pm, serave <ramirez.sebast...@gmail.comwrote:
How do i evaulate a mathematical expression that is entered in a text
field.
What exactly do you want? Why do you want to evaluate mathematical
expressions? Do you simply want the numerical value of y?
Exactly, thats what i need. The be explicit. the user enter the values
of the x`s and the program should return the y value, given teh math
equiation entered by the user.   This discussion thread is closed Replies have been disabled for this discussion.   Question stats  viewed: 3170
 replies: 14
 date asked: Aug 31 '08
