Ask Your Question

indiajoe's profile - activity

2023-08-07 20:05:52 +0100 received badge  Good Question (source)
2023-08-07 20:05:34 +0100 received badge  Good Answer (source)
2023-08-07 20:05:34 +0100 received badge  Enlightened (source)
2021-04-12 09:01:14 +0100 received badge  Famous Question (source)
2020-07-25 14:09:07 +0100 received badge  Famous Question (source)
2019-07-23 07:28:36 +0100 received badge  Popular Question (source)
2019-07-23 07:28:36 +0100 received badge  Notable Question (source)
2018-12-20 21:53:03 +0100 received badge  Famous Question (source)
2017-02-16 20:29:57 +0100 received badge  Notable Question (source)
2016-06-21 21:40:25 +0100 received badge  Notable Question (source)
2016-03-30 11:12:06 +0100 received badge  Famous Question (source)
2015-03-05 23:19:47 +0100 received badge  Popular Question (source)
2015-02-16 15:02:06 +0100 received badge  Nice Question (source)
2015-02-16 14:32:07 +0100 received badge  Popular Question (source)
2014-06-29 03:15:04 +0100 marked best answer printing equations in latex inside cell

How can I print equation in latex inside a cell in the sage's browser interface?

The %latex command converts the entire cell to latex. I only want to print certain equations in latex.

The latex(eqn) prints out the eqn in latex syntax, but it is not rendering and showing me the eqn in latex fonts.

I tried out the function 'view()'. It also is giving me the syntax as output, not the rendered latex eqn.

2014-06-29 03:15:00 +0100 marked best answer Dropping higher powers of a variable in an expression

Many a times in symbolic manipulations, I end up with lots of terms of higher powers of a variable. Is there a command to drop all the terms above a given power from a symbolic expression?

Eg: from an expression f(x)= x+ x^2 + x^3 + x^4

I want to get only upto 2nd order. i.e. g(x)= x + x^2

I also want to do this on a symbolic matrix.

This will be very useful for simplifying expressions upto lower order terms for further calculations.

2014-06-29 03:14:59 +0100 marked best answer 3d polar plot

I have to do a 3d polar plot. i.e. I have to make a 3d plot by rotating a 2d polar plot along the vertical axis.

The polar plot is of the form r=f(theta). But the polar_plot function in sage gives me only 2d plot. How do I get a 3D version of it?

I tried spherical_plot but it is not giving me the plot which I expect to be equivalent to the revolution surface I get from rotating the 2d polar plot along vertical axis.

Example:

show(polar_plot(sin(2*theta),theta,0,2*pi))

I wanted to plot this sin(2*theta) function as a 3d plot, by revolving it around by it's vertical axis. But the command

spherical_plot3d(sin(2*theta),(theta,0,2*pi),(x,0,pi))

Is not giving me that. It is giving me another shape instead.

Or Another Example: polar_plot of cos(theta)

I want to do a 3d polar plot of this to get a doughnut shape

I shall also give another example with pictures. The following plot is what I wanted using spherical3d plot

image description

But in sage, giving the same command is giving me this plot instead.

image description

What command should I give in sage to get a plot like the one we get from Mathematica?

2014-06-29 03:14:49 +0100 marked best answer Physics constants in sage.

Hi,

Are Physics constants like h (planks constant) , k (Boltzmann constant) etc.. available in sage? If yes, how can i use them? When i searched I found only math constants Pi, e etc..

-Thanks

indiajoe

2014-01-14 17:38:56 +0100 received badge  Notable Question (source)
2013-12-06 01:17:07 +0100 received badge  Famous Question (source)
2013-05-09 18:57:51 +0100 received badge  Great Question (source)
2013-02-18 21:35:38 +0100 received badge  Popular Question (source)
2013-01-26 04:41:32 +0100 received badge  Notable Question (source)
2012-12-14 02:29:32 +0100 commented answer evaluvating variable inside a function while integrating

@ndomes: Thankyou, This is fine. but i would have preferred something more simply to integrate a piecewise defined function. So that all the limits of function changes are defined inside the function and the outside integrations commands are independent of what was inside the function.

2012-12-13 07:59:31 +0100 commented answer evaluvating variable inside a function while integrating

I tried the Piecewise() function but now getting a Value error (Details I have updated in question)

2012-12-13 07:26:37 +0100 commented answer evaluvating variable inside a function while integrating

@ndomes : Thanks for the help. But what i really want is the function T2(x) to give different function output corresponding to the value of x. It is a piecewise defined function. How can i do that?

2012-12-13 01:54:10 +0100 asked a question evaluvating variable inside a function while integrating

I got a strange problem. The code to reproduce the problem is given below

from scipy.constants import h, c, k
def T2(x):
    a=11717  
    if x < 21500 : return a*(x**-0.53)
    else :
        print(x)  # Just for debugging
        return a*(x**-0.75)
# Blackbody Planky function
def B(Lambda,Temp):
    return 2*h*c**2/(Lambda**5 *(exp(h*c/(Lambda*k*Temp))-1))

def flux2(Lambda):
    return numerical_integral(2*pi*x*B(Lambda,T2(x)),7,2150)[0]

print 2.5*log(flux2(9000*10**-10))

The problem is inside the T2() function. Since the integral in x is from 7 to 2150, The if condition should get satisfied. and return the a(x*-0.53) . But instead it is evaluating the else condition. print x is printing the alphabet 'x' instead of the value of variable x it is supposed to take during each point in integral. I guess i have understood how these functions work inside an integral wrongly. What is it that I am doing wrong here?


Update: I instead tried the Piecewise() function to define T2() as follows,

a=11717
T2= Piecewise([[(0,215),a*(x**-0.53)],[(215,21500),a*(x**-0.75)]])

but inside the integral function I am getting ValueError

ValueError: Value not defined outside of domain.

2012-11-28 17:04:39 +0100 marked best answer def f(x): evaluvates individually but not inside plot

Using numerical_integral will allow you to produce a plot as follows.

def T(L): 
    ans=numerical_integral(4/sqrt(pi)*exp(-L)*(x^2)*exp(-x^2/4)/cosh(sqrt(L)*x),0,oo)
    return ans[0]

plot(lambda L: T(L),(L,5,7))
2012-11-28 17:04:33 +0100 commented answer def f(x): evaluvates individually but not inside plot

@calc314 Thankyou very much. This works for me. Though I am still curious why the integral() function didn't work.

2012-11-28 13:11:11 +0100 asked a question def f(x): evaluvates individually but not inside plot

Hi, I am stuck with a curious error. The code to reproduce error is given below. The function T basically integrates the function with a given value of L.

def T(L): return n(integral(4/sqrt(pi)*exp(-L)*(x^2)*exp(-x^2/4)/cosh(sqrt(L)*x),x,0,+Infinity))
plot(T,5,7)

The function T works fine if I ask

print T(5)

But it gives error, when i give the above mentioned plot command. What might be going wrong here?

2012-11-14 18:12:51 +0100 received badge  Famous Question (source)
2012-09-16 20:52:17 +0100 received badge  Notable Question (source)
2012-05-04 22:42:01 +0100 marked best answer Physics constants in sage.

Scipy, included in sage, has these constants:

sage: from scipy.constants import h, k
sage: h
6.6260693000000002e-34
sage: k
1.3806505000000001e-23

More details about what is in scipy.constants is available here

2012-05-02 16:52:10 +0100 received badge  Notable Question (source)
2012-02-26 22:15:01 +0100 received badge  Popular Question (source)
2012-02-20 12:40:21 +0100 received badge  Popular Question (source)