+ 1
Using Python For Iterating With An Equation
Hey guys, please I'm quite new to python but I'd like to know exactly how I could use the syntax to model an equation which will have it's variables as a list of values to enable me iterate the equation through each variable value on the list. I don't know if that makes any sense to anyone but I'd really appreciate any support I can get.
7 Respuestas
+ 3
Maybe something like this
https://code.sololearn.com/c0zvi0LqqBTg/?ref=app
+ 1
@Aymane Okay llet's say I have an equation 3x +2y - 1 = 2
and a list of values say [1,3,2,4,7,9,4] defined for the variable x, and a simiar list for the variable y. My intention is to write a body of code that helps iterate each of those values through the equation to provide individual answers to the expression, so that I can effectively extract the x and y values that produces a certain class of answer eg, if a particular x value and y value according to the predetermined list produces a resulting value above 50 when applied to the expression,, print the x and y values.
+ 1
My intention is to get appropriate values to plot a graph, but in order to do so, I would need to iterate a list of x and y variable values on an equation.
I don't know if it's clearer now
+ 1
Why don't you write z=3x+2y-1-2 and next realiaze a double for cycle primary on the x vector and next on the y vector, with the intent to evaluate the z variable on the cartesian product of the vector x and y?
+ 1
@Louis thanks for the code provided. That was exactly what I was looking for. Thanks also to all who provided their support. Bless
0
I don't really understand the question, can you give some examples ?
- 1
Hi. Do you want to solve an equation by iterative methods? In this case there are several different methods that you can implement. For example the Bisection method or the Newton-Raphson method.
You should define a function that contains the mathematical Expression that you want to solve and next give x values and get y values. After that you should check the convergence of the two members of your equation with some If cycles. If you know c++ you can visit my personal codes that treat the topic. Good luck.