formula

How to do a fractional power on BigDecimal in Java?

谁都会走 提交于 2019-11-26 04:27:33
问题 In my little project I need to do something like Math.pow(7777.66, 5555.44) only with VERY big numbers. I came across a few solutions: Use double - but the numbers are too big Use BigDecimal.pow but no support for fractional Use the X^(A+B)=X^A*X^B formula (B is the remainder of the second num), but again no support for big X or big A because I still convert to double Use some kind of Taylor series algorithm or something like that - I\'m not very good at math so this one is my last option if

How to draw sky chart? [closed]

回眸只為那壹抹淺笑 提交于 2019-11-26 03:45:06
问题 How do I draw a star chart like this? I have: A star database with coordinates (right ascension and declination) Observer coordinates (latitude, longitude) Time of observation I need a formula which considered these parameters. 回答1: stellar database google for: BSC (Bright star catalog) ~10K stars up to +6.5 mag (naked eye) Hipparcos ~118K stars up to +12 mag (telescopes) and also has parallax (3D coordinates) and many more Hipparcos is mine favorite. both can be downloaded freely in ASCII

How to use reference variables by character string in a formula?

时光怂恿深爱的人放手 提交于 2019-11-26 03:38:05
问题 In the minimal example below, I am trying to use the values of a character string vars in a regression formula. However, I am only able to pass the string of variable names (\"v2+v3+v4\") to the formula, not the real meaning of this string (e.g., \"v2\" is dat$v2). I know there are better ways to run the regression (e.g., lm(v1 ~ v2 + v3 + v4, data=dat) ). My situation is more complex, and I am trying to figure out how to use a character string in a formula. Any thoughts? Updated below code #

How to use reference variables by character string in a formula?

房东的猫 提交于 2019-11-26 03:11:12
问题 In the minimal example below, I am trying to use the values of a character string vars in a regression formula. However, I am only able to pass the string of variable names (\"v2+v3+v4\") to the formula, not the real meaning of this string (e.g., \"v2\" is dat$v2). I know there are better ways to run the regression (e.g., lm(v1 ~ v2 + v3 + v4, data=dat) ). My situation is more complex, and I am trying to figure out how to use a character string in a formula. Any thoughts? Updated below code #

Formula with dynamic number of variables

≯℡__Kan透↙ 提交于 2019-11-26 01:47:03
问题 Suppose, there is some data.frame foo_data_frame and one wants to find regression of the target column Y by some others columns. For that purpose usualy some formula and model are used. For example: linear_model <- lm(Y ~ FACTOR_NAME_1 + FACTOR_NAME_2, foo_data_frame) That does job well if the formula is coded statically. If it is desired to root over several models with the constant number of dependent variables (say, 2) it can be treated like that: for (i in seq_len(factor_number)) { for (j

Method for evaluating math expressions in Java

限于喜欢 提交于 2019-11-26 01:42:57
问题 In one of my projects I want to add a feature where the user can provide in a formula, for example sin (x + pi)/2 + 1 which I use in my Java app /** * The formula provided by the user */ private String formula; // = \"sin (x + pi)/2 + 1\" /* * Evaluates the formula and computes the result by using the * given value for x */ public double calc(double x) { Formula f = new Formula(formula); f.setVar(\"x\", x); return f.calc(); // or something similar } How can I evaluate math expressions? 回答1:

Formula px to dp, dp to px android

十年热恋 提交于 2019-11-26 01:04:48
问题 I am trying to calculate a variable amount of pixels to density independent pixels and vice-versa. This formula (px to dp): dp = (int)(px / (displayMetrics.densityDpi / 160)); does not work on small devices because it is divided by zero. This is my dp to px formula: px = (int)(dp * (displayMetrics.densityDpi / 160)); Could someone give me some pointers? 回答1: Note: The widely used solution above is based on displayMetrics.density . However, the docs explain that this value is a rounded value,

How to turn a string formula into a “real” formula

不问归期 提交于 2019-11-26 00:16:06
问题 I have 0,4*A1 in a cell (as a string). How can convert this \"string formula\" into a real formula and calculate its value, in another cell? 回答1: Evaluate might suit: http://www.mrexcel.com/forum/showthread.php?t=62067 Function Eval(Ref As String) Application.Volatile Eval = Evaluate(Ref) End Function 回答2: I Concatenated my formula as normal but at the start I had '= instead of = . Then I copy and paste as text to where I need it. Then I highlight the section saved as text and press ctrl + H

Formula px to dp, dp to px android

喜你入骨 提交于 2019-11-25 23:52:43
I am trying to calculate a variable amount of pixels to density independent pixels and vice-versa. This formula (px to dp): dp = (int)(px / (displayMetrics.densityDpi / 160)); does not work on small devices because it is divided by zero. This is my dp to px formula: px = (int)(dp * (displayMetrics.densityDpi / 160)); Could someone give me some pointers? Bachi Note: The widely used solution above is based on displayMetrics.density . However, the docs explain that this value is a rounded value, used with the screen 'buckets'. Eg. on my Nexus 10 it returns 2, where the real value would be 298dpi