mathematical-expressions

Adding Conditionals & Functions to a Math Parser

寵の児 提交于 2019-12-12 20:17:14
问题 I have a binary tree based mathematical expression parser I built, which works great for 'normal' math, like: (3.5 * 2) ^ 1 / (1 << 6) . however, I would like to expand it a little to add a ternary selection operator, mirroring the one from C: {expr} ? {true-expr} : {false-expr} . I would also like to add functions, like sin(x) or ave(...) . I however have no clue to how the handle this (due to the way the evaluation works), nor can I find anything on the web that covers this, atleast in a

Predicting price using previous prices with R and Neural Networks (neuralnet)

∥☆過路亽.° 提交于 2019-12-09 07:33:28
问题 Within the R Neural Network page, I am using the neural network function to attempt to predict stock price. Training data contains columns High,Low,Open,Close. myformula <- close ~ High+Low+Open neuralnet(myformula,data=train_,hidden=c(5,3),linear.output=T) My question, Given the below data example could you tell me what the formula would look like. I have a table with columns "High","Low","Open","Close" it has two rows of values, each row represents a candle stick for the day. So the two

How to know the result of Complex has one or more real roots

半腔热情 提交于 2019-12-08 10:34:25
问题 I want to use Complex to calculate the minus pow. As $(-10)^(1/3)$ that use the Math.Pow will get the NAN. But when I use Complex.Pow, I can get the result. Complex c = Complex.Pow(-10, 1.0/3); var r = c.Magnitude;//2.1544346900318843 But the real result is -2.1544346900318843. I don't know the result is positive for the Magnitude is Abs. I can't add -1* in all the result for the pow can make the result is positive. (-10)^(2/3) should get the positive result. How can I judge the result is

FullSimply Inequalities and then rearranging them in Mathematica 7

£可爱£侵袭症+ 提交于 2019-12-07 06:48:00
问题 I am using Mathematica 7 in the notebook interface and I want to rearrange an inequality so that I get a certain variable on one side. For eg. FullSimplify[x^3+L+r>3x^3+2r] Gives L > r + 2 x^3 However, I want : r < L-2x^3 Is there anyway we can instruct FullSimplify to order variables in a particular way? I am using Mathematica for presentation as well so, the way I arrange the variables is important to me. Thanks SR Edit: I tried Reduce, while that works for this example, it does not work

Convert stroke data to SCG Ink format

℡╲_俬逩灬. 提交于 2019-12-06 11:37:30
问题 I'd like to use Seshat—a handwritten math expression parser—for a project I'm working on, but I'm having some trouble understanding how to provide the program its proper input, an InkML or SCG Ink file. I've taken a long look at an online example that exists here, and I see that they get a Javascript array of stroke information from an HTML Canvas field with this JS library applied, but I don't know what happens that array after it gets POSTed to their server. I've read the SCG Ink spec, and

How to get the size of a number in .net?

混江龙づ霸主 提交于 2019-12-06 05:25:59
问题 I want with a given double number to return its "size" (known as |number|, or number of digit without the numbers after the dot), for example: 12.324654 -> 2 12 -> 2 0.99 -> 0 1.01 -> 1 901 -> 3 -0.99 -> 0 -9.999 -> 1 There must be a function is .net that I dont familiar with that does it.. Thanks. 回答1: ((int)Math.Abs(12.324654)).ToString().Length Math.Abs will convert to positive number (don't want to count the negative sign) (int) will drop the digits following the decimal point ToString()

FullSimply Inequalities and then rearranging them in Mathematica 7

筅森魡賤 提交于 2019-12-05 10:12:57
I am using Mathematica 7 in the notebook interface and I want to rearrange an inequality so that I get a certain variable on one side. For eg. FullSimplify[x^3+L+r>3x^3+2r] Gives L > r + 2 x^3 However, I want : r < L-2x^3 Is there anyway we can instruct FullSimplify to order variables in a particular way? I am using Mathematica for presentation as well so, the way I arrange the variables is important to me. Thanks SR Edit: I tried Reduce, while that works for this example, it does not work for the actual expression I have, I get an error saying, This system cannot be solved with the methods

Writing variables as subscripts in math mode

主宰稳场 提交于 2019-12-05 03:44:02
问题 I am trying to plot some data, using a for loop to plot distributions. Now I want to label those distributions according to the loop counter as the subscript in math notation. This is where I am with this at the moment. import matplotlib.pyplot as plt import numpy as np import matplotlib.mlab as mlab mean = [10,12,16,22,25] variance = [3,6,8,10,12] x = np.linspace(0,40,1000) for i in range(4): sigma = np.sqrt(variance[i]) y = mlab.normpdf(x,mean[i],sigma) plt.plot(x,y,label=$v_i$) # where i

Avoid Overflow when Calculating π by Evaluating a Series Using 16-bit Arithmetic?

£可爱£侵袭症+ 提交于 2019-12-04 23:08:19
I'm trying to write a program that calculates decimal digits of π to 1000 digits or more. To practice low-level programming for fun, the final program will be written in assembly, on a 8-bit CPU that has no multiplication or division, and only performs 16-bit additions. To ease the implementation, it's desirable to be able to use only 16-bit unsigned integer operations, and use an iterative algorithm. Speed is not a major concern. And fast multiplication and division is beyond the scope of this question, so don't consider those issues as well. Before implementing it in assembly, I'm still

Writing variables as subscripts in math mode

余生长醉 提交于 2019-12-04 16:31:08
I am trying to plot some data, using a for loop to plot distributions. Now I want to label those distributions according to the loop counter as the subscript in math notation. This is where I am with this at the moment. import matplotlib.pyplot as plt import numpy as np import matplotlib.mlab as mlab mean = [10,12,16,22,25] variance = [3,6,8,10,12] x = np.linspace(0,40,1000) for i in range(4): sigma = np.sqrt(variance[i]) y = mlab.normpdf(x,mean[i],sigma) plt.plot(x,y,label=$v_i$) # where i is the variable i want to use to label. I should also be able to use elements from an array, say array[i