[Solved] How to solve this mathematical equation in php [closed]

Just group the D’s first and dont hardcode the indices, use $i $S = array(); $D = array(); $M = array(“1″=>30,”2″=>31,”3″=>30); $Y = array(“1″=>360,”2″=>360,”3″=>360); $O = 30000; $P = 0.3; $N = 10509.74; for($i = 1, $size = count($M); $i <= $size; $i++){ $final_D = 0; // group the D’s first (O-D1), (O-D1-D2), … and … Read more

[Solved] Solving an equation with python

You can do things like this with the sympy library. http://docs.sympy.org/dev/index.html >>> from sympy import * >>> from sympy.solvers import solve >>> ca, ra = symbols(“ca ra”) >>> eq = -ra + (1.5 * (ca – (ra/2))/(1 + 0.8 * (ca – (ra/2)))) >>> print(eq) -ra + (1.5*ca – 0.75*ra)/(0.8*ca – 0.4*ra + 1) >>> … Read more

[Solved] how to evaluate an equation with python [closed]

You can loop over values like this: for x in [-60.0, -45.0, -30.0]: # etc; notice how the .0 specifies a float print(‘D({0}) = {1}’.format(x, A*math.cos(x)**2+B*math.sin(x)+C)) If you intend for the output to be machine-readable, maybe change the format string to something like ‘{0},{1}’ for simple CSV output. Just print will print nothing (well, or … Read more

[Solved] how to split a string for equation

To extract characters from a string and to store them into a Character Array Simple Method (Using string indexing): #include<iostream> using namespace std; // Using the namespace std to use string. int main(int argc, char** argv) { string input; cout << “Enter a string: “; cin>>input; // To read the input from the user. int … Read more