I have used Ubuntu to open a Python project, via VSC, in order to solve for multiple variables in a linear algebra scenario. To show the code:
from sympy.solvers import solve
from sympy import Symbol
x = Symbol('x')
solve[(.85*x - 17.59, x)
I end up solving for X. However, I have an array:
array([[17.594],
[15.79 ],
[11.31 ],
[16.39 ],
[13.87 ],
[16.99 ]])
I would like to use the following array and solve:
.85x - ([[17.594], = 0
.85x = [15.79 ], = 0
.85x - [11.31 ], = 0
.85x - [16.39 ], = 0
.85x - [13.87 ], = 0
.85x - [16.99 ]]) = 0
I am attempting to subtract the array from .85x while solving for x for each individual number in the array. I do not want to do this individually for each number; I want to be able to solve for each value of x all at once (I am going to have 1000s of numbers in the array).
I have been trying for hours to find a way to do this with no luck. Some help would be greatly appreciated.
3
Answers
Correct me if I’m wrong, but if that’s a NumPy array, it’s easier to solve this with simple algebra:
It can be done.
Is this what you really want? Isn’t it easier with Numpy, as in wjandrea‘s answer?
You can use a list comprehension to solve the value of for each of the element in the array.