Calculating mathematical functions in Android

I'd like to build myself a small app to get my homework done faster. I want the user to be able to enter any function like f(x)=x2-5x+3 or f(x)=x3/(2x-2) and then return a list of y-values for specific x-values. For f(x)=x2 it would look something like this: - x=-2 y=4 - x=-1 y=1 - x=0 y=0 - x=1 y=1 - x=2 y=4 - x=3 y=9 - x=4 y=16 And so on. Is there any function in the math class of java that takes in a mathematical function and an x-value and outputs the according y-value or do I need to have some kind of parser of my own? **Edit** [exp4j][1] seems to be the right thing for me. This library is very small, fast and easy to use. [1]:
You can build an expression parser in ANTLR:… or use the JVM's scripting facilities, as is shown here:…

以上就是Calculating mathematical functions in Android的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准