Ask Your Question

happys5's profile - activity

2020-11-13 03:10:17 -0600 received badge  Famous Question (source)
2020-09-29 15:20:32 -0600 received badge  Famous Question (source)
2020-07-05 11:26:57 -0600 received badge  Notable Question (source)
2020-04-16 21:25:17 -0600 received badge  Famous Question (source)
2020-01-07 15:55:46 -0600 received badge  Famous Question (source)
2019-12-24 23:39:10 -0600 received badge  Famous Question (source)
2019-12-24 09:05:09 -0600 received badge  Self-Learner (source)
2019-12-24 09:05:09 -0600 received badge  Teacher (source)
2019-12-09 18:58:33 -0600 received badge  Popular Question (source)
2019-10-31 07:47:48 -0600 received badge  Notable Question (source)
2019-10-31 07:47:48 -0600 received badge  Popular Question (source)
2019-07-29 06:37:28 -0600 received badge  Notable Question (source)
2019-06-01 05:30:25 -0600 received badge  Popular Question (source)
2019-04-01 09:58:30 -0600 received badge  Notable Question (source)
2019-02-02 08:08:43 -0600 received badge  Popular Question (source)
2018-12-15 04:56:09 -0600 received badge  Notable Question (source)
2018-12-13 15:01:56 -0600 received badge  Popular Question (source)
2018-06-11 05:32:04 -0600 received badge  Popular Question (source)
2018-03-03 04:45:39 -0600 received badge  Popular Question (source)
2018-01-23 21:56:04 -0600 asked a question Find all roots of an equation


I have tried the following: used solve() by itself and with "to_solve_poly=True", imported simpy, tried find_root, and tried eq.roots(). find_root() gave me one root when there are several between 0,11.

How can I solve for all the roots in a range. Here is my final code.


PI = 2*asin(1.0)
eq = exp(-x)-sin(0.5*PI*x)==0
show(plot(exp(-x)-sin(0.5*PI*x), x, xmin = -10, xmax = 10, ymin =-10, ymax=10))
eq.find_root(0, 11)
2017-08-09 12:19:40 -0600 received badge  Notable Question (source)
2017-07-15 10:15:53 -0600 received badge  Popular Question (source)
2017-07-09 11:29:27 -0600 commented answer If Comprehension in list

Thanks for the help!

2017-07-09 09:49:24 -0600 asked a question If Comprehension in list


I am knew to SageMath and Python. I hope to learn Python after I finish C++.

I would like to compare two lists and place the larger value from list L2 in another list if it is greater than L3 but not in the list if less than. Here is my try:

L2 =[sum(divisors(i))-i for i in range(1,100,1)]
print L2

L3 =[i for i in range(1,100,1)]
print L3

L4 =[L2[i] if L2[i] > L3[i] for i in range(1,100,1)]
print L4

I get the following error:

File "<ipython-input-1-01c49b9c5559>", line 20
    L4 =[L2[i] if L2[i] > L3[i] for i in range(Integer(1),Integer(100),Integer(1))]
SyntaxError: invalid syntax
2017-07-08 17:58:34 -0600 answered a question Creating list within an outer for loop counter


I finally figured out how to create the above in one list. Instead of multiple rows with one element, I have one row with multiple elements. I don't know if that is the right "descriptive language" in Sage or python talk so just copy and paste, compare to above and you will see what I mean.

L1 =[divisors(i) for i in range(1,100,1)] 
print L1

L2 =[sum(divisors(i))-i for i in range(1,100,1)]
print L2
2017-07-08 13:43:11 -0600 asked a question Creating list within an outer for loop counter


I want to create one list for L. I gave an example from the list tutorial(list1) that does what I want to do. I believe I have to include the for loop inside the brackets [] but cannot figure it out. I do not know how to program in Python. I am learning C++ now and hope to learn Python next.

for i in range (1,100,1):
    div = divisors(i)
    length = len(div)
    L = [sum(div[k] for k in range(length))-i]
    print i, 

    print L

list1 =[j for j in range(6)] 
print list1


2017-07-06 14:28:27 -0600 commented answer Import Text.txt file contents from a windows computer to sagecell.


Yeah, they were opened and closed by single quotation marks when I tried to import. I just added the double quotation when I typed it in here. Sorry.

2017-07-05 20:47:54 -0600 asked a question Import Text.txt file contents from a windows computer to sagecell.


The following code will work on my Linux computer if I use the "/usual path/" in Linux but I cannot get Sage to recognize my Windows path. My code

with open('C:\Users\miram\OneDrive\Documents\Programming\Original.txt', 'r') as f: 
    L = f.readlines()

I have also tried the path

with open('C:\\Users\\miram\\OneDrive\\Documents\\Programming\\Original.txt', 'r') as f: 
        L = f.readlines()

I have also tried the path

 with open('C:\\Text\\22.PE.Orig.List.txt', 'r') as f: 
            L = f.readlines()

and with one backslash.

I get the following error:

IOError: [Errno 2] No such file or directory: 'C:\\Text\\22.PE.Orig.List.txt'

What I want to do, as can be seen, is import a text file into SageMath so that I can work with the list created.

I am following: and have followed the advice for my Linux machine and have not had a problem. I need to do it on my Windows computer, though.

I think my problem is that I am using a sagecell server. Is that true?

2017-06-20 14:26:35 -0600 commented answer to_poly_solve problem?


When I use sympy for:

differ = -9.81000000000000*t - 23.73831775700935*e^(-1/2*t + 11/2) + 154.299065420560 == 0
import sympy

I get the following error text:

line 220, in __call__ return self.relation(ex, operator) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/sage/symbolic/", line 340, in relation raise NotImplementedError("relation") NotImplementedError: relation

2017-06-20 14:10:35 -0600 commented answer to_poly_solve problem?

Thanks! find_root worked just fine.

2017-06-19 21:15:34 -0600 asked a question to_poly_solve problem?


I have:

var ('N,m,sec,a,t,c')

T = (1.27 * 10^6)
Fg = ((9.81*107000))
a = ((T-Fg)/107000)
a = 2.05915887850467

v = a*t
P3 = plot(v, (t,0,11))

y = 1.029579439252335*t^2

P1 = plot(y, (t,0,12))

T1 = 1.27*e^(-(t-11)/2) * 10^6
Fg = 9.81*107000
a1 =(T1-Fg)/107000

v1 = a1.integral(t)
v1 = -9.81*t - 23.738317757009348*e^(-1/2*t + 11/2) + 154.299065420560
P4 = plot(v1, (t,11,22))


y1 = -4.905*t^2 + 154.29906542056*t + 47.476635514018696*e^(-1/2*t + 11/2) -1026.68224299065

P2 = plot (y1, (t,12,22))

P = P1 + P2; 

Impact = y1.find_root(21,22)

P5 = P3 + P4

differentiate = diff(y1, t)

solve(-9.81000000000000*t - 23.73831775700935*e^(-1/2*t + 11/2) + 154.299065420560 == 0, t, to_poly_solve=True)

I am learning SageMath.

When I try to solve the last solve equation that has an exponential with a "t" (the last line in the code) while using to_poly_solve=True, I get the following error:

TypeError: 'sage.symbolic.expression.Expression' object does not support indexing

I would like to solve for "t" so that I can find the maximum of a function.

Thanks in advance.

2017-06-18 11:41:03 -0600 answered a question Plot Multiple 3D Graphs that overlap


I figured out how to graph two graphs in 3D that overlap. The key is "implicit_plot3d." I provide an example. Since x^2 is missing in the equation (y^2 + z^2), the cylinder can be viewed down the x axis. If y^2 is missing (x^2 + z^2), the cylinder will be viewed down the y axis. If z^2 is missing, ect.

var ('x y z')

implicit_plot3d(y^2+z^2==36, (x,-6,6), (y,-6,6), (z,-6, 6), color="blue", figsize=4, opacity=.3, axes="true" ) + plot3d(x^2 + y^2, (-1,1),(-2.3,2.3))
2017-06-17 14:18:10 -0600 asked a question Plot Multiple 3D Graphs that overlap


I can graph multiple 3D graphs by adding them together but I can not get them to overlap the way I want. I would like to be able to flip the axis. As an example, I would like to be able to graph the height of the cylindrical_plot3d along the x or y axes in addition to the z axes. Same for the 3d parabola.

theta,y=var('theta,y')#start was z
cylindrical_plot3d(10,(theta,0,2*pi),(y,-2,2)) + plot3d(x^2, (-1,1),(-1,1))

Thanks in advance!

2017-06-17 13:37:01 -0600 commented answer Numerically Solve a Symbolic Equation

Thanks, Philipp!

2017-06-17 13:23:09 -0600 received badge  Supporter (source)
2017-06-17 02:40:23 -0600 received badge  Student (source)
2017-06-16 21:26:35 -0600 asked a question Numerically Solve a Symbolic Equation


In truth, I am feeling like an idiot but it has been a long while since I have done math.

What I want to do is find the intersection points between a parabola and a circle. After I put both equations in x and set them equal, I have:

solve (sqrt(16-x^2) - 1/4*x^2-1.28==0, x)

Problem is, I get the following for answers:

[x == -2/5*sqrt(25*sqrt(-x^2 + 16) - 32), x == 2/5*sqrt(25*sqrt(-x^2 + 16) - 32)]

If I need to numerically solve the equation, which I think I must do, how do I do it in Sage?

2017-06-01 16:45:47 -0600 commented answer Export Answer To Text File

I am still making a mistake. I have tried single backslash and double backslash with no luck. I have also tried capital "C" and lower case "c". My code mirrors yours other than that.

sage: s = str(2^1000)
sage: f = open('C:\Users\miram\OneDrive\Documents\Sage\test.txt', 'w')
sage: f.write(s)
sage: f.close()

Any advice?

2017-05-30 19:56:02 -0600 asked a question Export Answer To Text File


I have read the available suggestions and they did not work.

I would like to output the number generated by 2^1000 to a text file so that I can import to my C++ program.

Please help me along.

2017-05-27 01:48:42 -0600 answered a question 10,001 Prime Number is different in SageMath than Project Euler

Well, I am in a predicament. I figured out why there is a difference but the answer will give away the answer to a Project Euler answer. It is a simple answer and I should have never posted this question. Sadly, I have given away one Project Euler answer.

The answer is that the unrank(), like an array, starts out at 0. So, 10,000 is actually the 10,001 prime.

2017-05-26 13:48:41 -0600 asked a question 10,001 Prime Number is different in SageMath than Project Euler


I used C++ to produce a much slower Prime number generator but my 10,001 prime number matched Project Euler's result.

The 10,001 number from SageMath is slightly different than my and Project Euler's result. I would provide the value but Project Euler has asked members not to share answers or code online so that others can enjoy their experience solving the problem. I used:

p = Primes()