评估代数表达式 [英] evaluate an algebraic expression
问题描述
如何评估在文本中输入的数学表达式
字段。
Ex:
文本字段:
Xo = 23
X1 = 250
表达式:y = Xoe ^(x1 + Xo)-cos(X0 + X1)+ 23Xo
如何管理?
tx
8月31日上午10:29 *,serave< ramirez.sebast ... @ gmail.comwrote:
如何评估数学表达式在文本中输入
字段。
Ex:
文本字段:
Xo = 23
X1 = 250
表达式:y = Xoe ^(x1 + Xo)-cos(X0 + X1)+ 23Xo
我该如何管理?
在等式的右边有X0,x1,Xo和X1,但是
只定义Xo和X1。因此,除非您使用某些
数值定义另一个值,否则无法将该等式解析为y的数值。也许这个等式中有一个拼写错误?如果你的意思是
来简化所写的等式,这是代数中的一个问题。
如果你定义另一个值或纠正一个可能的拼写错误,要么
php或Javascript的数学函数可以用来解决
等式(y的值可能是x1的值?)因为
简单的数学函数,指数和cos都包含在
语言中。
在8月31日,17:29,serave< ; ramirez.sebast ... @ gmail.comwrote:
Xo = 23
X1 = 250
表达式:y = Xoe ^(x1 + Xo)-cos(X0 + X1)+ 23Xo
要在PHP中执行此操作,首先要解析表达式将其从
字符串转换为结构。您必须使解析器执行此操作。接下来,你将
计算结果。
在PHP中执行此操作远非微不足道。更好的方法可能是使用像bc这样的东西( http://www.gnu.org/software/bc/ )或另一个
程序来为你评估表达式。
< blockquote>你知道是否已经写了一些东西,也许是在javascript
或者caise中我会花很多时间再做一遍。
可能是那些已经写过的人了吗?
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
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.
On 31 aug, 17:29, serave <ramirez.sebast...@gmail.comwrote:Xo=23
X1= 250
Expression: y = Xoe^(x1+Xo)-cos(X0+X1)+23XoTo 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.
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屋!