Sep-09-2019, 09:22 PM
(This post was last modified: Sep-11-2019, 04:34 AM by newbieAuggie2019.)
Hi again!
For what I have read, it seems that numpy doesn't work very well with huge amounts of data, so I thought of a way to go around it: I have modified the program to calculate the different solutions to your equation, by making a loop, calculating the solution for each value of 'y', for each value of 'x' and I got many solutions (too many to be printed here, but you can run the program on your own). Nevertheless, there are some warnings I noticed that I comment further down:
As I indicated above, due to some values (for instance, the '0' value), I got also two RuntimeWarning messages:
Hi once again!
As you mention using a plot to display the pairs (x,y), I tried to do it with matplot, but it gives error warnings, but even so, it might give you some ideas:
All the best,
For what I have read, it seems that numpy doesn't work very well with huge amounts of data, so I thought of a way to go around it: I have modified the program to calculate the different solutions to your equation, by making a loop, calculating the solution for each value of 'y', for each value of 'x' and I got many solutions (too many to be printed here, but you can run the program on your own). Nevertheless, there are some warnings I noticed that I comment further down:
import numpy as np x = np.arange(4,12,.01) bigx = len(x) print("\nThe matrix 'x' has", bigx, "elements.") y = np.arange(0,18,.01) bigy = len(y) print("The matrix 'y' has", bigy, "elements.") mother_of_matrices = bigx*bigy print("Therefore, the interaction of matrices 'x' and 'y' produces a huge matrix of:", mother_of_matrices, "elements.") k = 10/(6+x) print('\n\nThese are the values for "x":\n\n', x) print('\n\nThese are the values for "y":\n\n', y) print('\n\nThese are the values for "k":\n\n', k) print('\n\nThese are the values for "x" in the equation:\n\n', x) for x in x: for y in y: x = ((y**(1/k)-(y-6)**(1/k))/6)**(k/(1-k)) print(x)
As I indicated above, due to some values (for instance, the '0' value), I got also two RuntimeWarning messages:
Error:Warning (from warnings module):
File "C:/Users/User1/AppData/Local/Programs/Python/Python37/equations_04.py", line 22
x = ((y**(1/k)-(y-6)**(1/k))/6)**(k/(1-k))
RuntimeWarning: invalid value encountered in power
Warning (from warnings module):
File "C:/Users/User1/AppData/Local/Programs/Python/Python37/equations_04.py", line 22
x = ((y**(1/k)-(y-6)**(1/k))/6)**(k/(1-k))
RuntimeWarning: divide by zero encountered in true_divide
and also this one at the end of the running time:Error:Traceback (most recent call last):
File "C:/Users/User1/AppData/Local/Programs/Python/Python37/equations_04.py", line 21, in <module>
for y in y:
TypeError: 'numpy.float64' object is not iterable
I hope it helps,Hi once again!
As you mention using a plot to display the pairs (x,y), I tried to do it with matplot, but it gives error warnings, but even so, it might give you some ideas:
import numpy as np import matplotlib.pyplot as plt x = np.arange(4,12,.01) bigx = len(x) print("\nThe matrix 'x' has", bigx, "elements.") y = np.arange(0,18,.01) bigy = len(y) print("The matrix 'y' has", bigy, "elements.") mother_of_matrices = bigx*bigy print("Therefore, the interaction of matrices 'x' and 'y' produces a huge matrix of:", mother_of_matrices, "elements.") k = 10/(6+x) print('\n\nThese are the values for "x":\n\n', x) print('\n\nThese are the values for "y":\n\n', y) print('\n\nThese are the values for "k":\n\n', k) print('\n\nThese are the values for "x" in the equation:\n\n', x) for x in x: for y in y: x = ((y**(1/k)-(y-6)**(1/k))/6)**(k/(1-k)) plt.scatter(x,y) plt.show()and here are the errors related to scatter in matplot:
Error:Traceback (most recent call last):
File "C:/Users/User1/AppData/Local/Programs/Python/Python37/equations_06.py", line 24, in <module>
plt.scatter(x,y)
File "C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\pyplot.py", line 2847, in scatter
None else {}), **kwargs)
File "C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\__init__.py", line 1601, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_axes.py", line 4444, in scatter
raise ValueError("x and y must be the same size")
ValueError: x and y must be the same size
About previous warning messages, maybe you could make some exception commands to avoid dividing by '0', or to prevent encountering invalid values in power...All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs