sage code:
%time
x = srange(1,10,0.000001);
for k in range(1,len(x)):
if abs(sin(x[k])*x[k]^2 + cos(x[k])*x[k]^2 + x[k] + cos(sin(x[k]))^2) <
0.0001:
print("Valor(y):",sin(x[k])*x[k]^2+cos(x[k])*x[k]^2+x[k]+cos(sin(x[k]))^2,"
. Raiz(x): ",x[k])
print("fim")
out: 158.45s
----------------------------------------------------------------------------
python code:
start = time.time()
import numpy as np
import time
x = np.arange(1,10,0.000001);
for k in range(1,len(x)):
if abs(np.sin(x[k])*x[k]**2 + np.cos(x[k])*x[k]**2 + x[k] +
np.cos(np.sin(x[k]))**2) < 0.0001:
print("Valor(y):",np.sin(x[k])*x[k]**2+np.cos(x[k])*x[k]**2+x[k]+np.cos(np.sin(x[k]))**2,"
. Raiz(x): ",x[k])
print("fim")
end = time.time()
elapsed = end - start
print(elapsed)
out: 45.16s
PC Avell b155max: I5 haswell , 8GBDDR3, NetRunner17
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.