用javascript求解方程 [英] Solving equation with javascript

查看:164
本文介绍了用javascript求解方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道如何使用一个输入字段来解决javascript中的联立方程式,设置像2x + 3y + 8 = 0这样的方程式并在不使用三个输入字段的情况下解决它,但是我仍然能够理解它我需要帮助,我真的不知道这个问题是否被接受,但我需要一个答案请



我尝试了什么:



i已谷歌但没有解决方案

i have being wondering how to solve simultaneous equation in javascript using only one input field, to set the equation like this 2x + 3y + 8 = 0 and solve it without using three input field,but i can,t still figure it out i need help,i don't really know if this question is accepted here but i need an answer please

What I have tried:

i have google it out but no solution yet

推荐答案

首先限制自己解决类似的事情:

(用户输入)Ax + By = C(仅使用'x'和'y'表示要解决的变量)

删除所有空格,以便得到:

Ax + By = C(这使得解析更容易,因为任何MINUS in(Ax - By = C)成为系数的一部分)

使用等效的(C函数)strchr ()搜索'x'然后'y'然后'='来获得A,B和B的值。 C分别(当然你必须将数字的ascii值转换为纯数字 - 你自己的atoi()或atof())。



然后你可以使用要解决的决定因素。以下只是提供一步一步细节的一个链接 - 搜索google determinant equation 2X2:

2x2系统的决定因素和Cramer规则1 | Coolmath.com [ ^ ]
First restrict yourself to solving something like:
(user input) Ax + By = C (use only 'x' and 'y' for variables to solve)
Remove all spaces so that you get:
Ax+By=C (this makes parsing easier since any MINUS in (Ax - By = C) becomes part of the coefficient)
Use the equivalent of (C function) strchr() to search for 'x' then 'y' and then '=' to get the values of A, B & C respectively (of course you will have to convert the ascii values of digits to plain numeric - your own atoi() or atof()).

You can then use determinants to solve. The following is just one link that provides step by step details - search google determinant equation 2X2:
"Determinants and Cramer's Rule for 2x2 Systems 1 | Coolmath.com[^]


这篇关于用javascript求解方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆