Convert string to math function x: f (x)?

Hi, I am new to Android programming. I am working on a graphing calculator, but I still have a problem converting a function to math

For example:

y=cos(x^2)-ln(x) 

should look like

 y=Math.cos(x*x) - Math.log(x) 

And how do we do it.

thank

0
android math android-library
Jan 15 '14 at 12:31
source share
1 answer

I assume you want to convert String to float or double?

 String input = "3.14"; float x = Float.parseFloat(input); 

This code converts the string "3.14" to a float. You can use this float in the function described by you in the question.

EDIT: If you want to convert the full String function to Java code, you must restrict the input to buttons. For example, add a button called "Cos" and remember, in the code the user wants to use the Cosinus function. Then the user enters a value and presses "Enter". The code knows that it must use the cosinus function, and x is the value entered in EditText. This value should be parsed using Float.parseFloat ().

0
Jan 15 '14 at 13:02
source share



All Articles