Ask Your Question

happys5's profile - activity

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

Hello,

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.

  var('PI')

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 19:19:40 +0200 received badge  Notable Question (source)
2017-07-15 17:15:53 +0200 received badge  Popular Question (source)
2017-07-09 18:29:27 +0200 commented answer If Comprehension in list

Thanks for the help!

2017-07-09 16:49:24 +0200 asked a question If Comprehension in list

Hello,

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-09 00:58:34 +0200 answered a question Creating list within an outer for loop counter

Hello,

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 20:43:11 +0200 asked a question Creating list within an outer for loop counter

Hello,

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

Thanks

2017-07-06 21:28:27 +0200 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-06 03:47:54 +0200 asked a question Import Text.txt file contents from a windows computer to sagecell.

Hello,

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: https://ask.sagemath.org/question/287... 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 21:26:35 +0200 commented answer to_poly_solve problem?

Hello,

When I use sympy for:

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

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/expression_conversions.py", line 340, in relation raise NotImplementedError("relation") NotImplementedError: relation

2017-06-20 21:10:35 +0200 commented answer to_poly_solve problem?

Thanks! find_root worked just fine.

2017-06-20 04:15:34 +0200 asked a question to_poly_solve problem?

Hello,

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))

v.integral(t)
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))

v1.integral(t)

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; 
show(P)

Impact = y1.find_root(21,22)
Impact

P5 = P3 + P4
show(P5)

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 18:41:03 +0200 answered a question Plot Multiple 3D Graphs that overlap

Hello,

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 21:18:10 +0200 asked a question Plot Multiple 3D Graphs that overlap

Hello,

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.

var('y,z')
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 20:37:01 +0200 commented answer Numerically Solve a Symbolic Equation

Thanks, Philipp!

2017-06-17 20:23:09 +0200 received badge  Supporter (source)
2017-06-17 09:40:23 +0200 received badge  Student (source)
2017-06-17 04:26:35 +0200 asked a question Numerically Solve a Symbolic Equation

Hello,

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:

var('y')
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 23:45:47 +0200 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-31 02:56:02 +0200 asked a question Export Answer To Text File

Hello,

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.