Ask Your Question

Hans's profile - activity

2020-11-30 19:31:48 +0200 received badge  Popular Question (source)
2020-09-21 17:20:50 +0200 received badge  Notable Question (source)
2020-06-11 02:26:39 +0200 received badge  Famous Question (source)
2020-06-11 02:26:39 +0200 received badge  Notable Question (source)
2020-06-11 02:26:39 +0200 received badge  Popular Question (source)
2020-02-15 01:58:09 +0200 received badge  Popular Question (source)
2019-11-01 15:02:38 +0200 received badge  Nice Question (source)
2019-11-01 03:57:18 +0200 commented question How to solve this algebraic equation by SageMath (rather than by hand)

@rburing and @Emmanuel Charpentier: I am sorry that I did not make the purpose of this question clear. I have now edited the question to clarify it. Please read particularly the note. It is not to find the inverse function per se by hand, but to coax SageMath to do it.

2019-10-31 09:24:28 +0200 asked a question How to solve this algebraic equation by SageMath (rather than by hand)

$$u = \frac{\sqrt{a^2+(r+t)^2}-\sqrt{a^2+(r-t)^2}}{2r}$$ How does one solve for $t$ in terms of all the other variables using SageMath?

Note: The purpose of this problem is not to find the solution per se, since we can solve it easily by hand, but to solve it completely by the machine algebra in SageMath. I am having difficulty coaxing SageMath to do that.

I tried the following SageMath code but failed to find the solution. What is the correct script?

u,r,t,a = var('u','r','t','a') 
g = (sqrt(a^2 + (r+t)^2) - sqrt(a^2 + (r-t)^2))/(2*r) 
ae = (g==u)
view(solve(ae,t))

The output is:

sqrt(a^2 + r^2 + 2rt + t^2) == 2ru + sqrt(a^2 + r^2 - 2rt + t^2)

However, this is not the desired solution.

2018-11-13 23:36:46 +0200 received badge  Famous Question (source)
2018-11-03 01:14:12 +0200 received badge  Good Question (source)
2018-11-02 00:21:38 +0200 asked a question Term collection in a fractional power series expansion

In the following SageMath code, I attempt to expand a function in terms of the dyadic powers of $t$:

var('t dt sigma1 B1 phi1 dB1');

S1(t,B1) = exp(-1/2sigma1^2t+sigma1*B1);

g=simplify(taylor(S1(dt,dB1),(dt,0),(dB1,0),3))

g1 = g.subs({dB1: phi1*dt^(1/2)}).full_simplify().maxima_methods().collectterms(dt);

view(g1)

However, I obtain the following output which no collection of the dyadic powers of $t$:

-1/48dt^3sigma1^6 - 1/8(2dt^2phi1^2 - dt^2)sigma1^4 + 1/2(dtphi1^2 - dt)sigma1^2 + 1/24(3dt^2phi1sigma1^5 + 4(dtphi1^3 - 3dtphi1)sigma1^3 + 24phi1sigma1)*sqrt(dt) + 1

How would one fix it?

2018-11-01 22:46:01 +0200 received badge  Nice Question (source)
2018-11-01 20:57:53 +0200 commented answer Substituting a differential equation into an expression

Impressive! I am digesting your answer. What does the * in 'new_operator(*[self(_) for _ in ex.operands()])' do?

2018-11-01 07:57:04 +0200 asked a question Substituting a differential equation into an expression

Say I have a (heat) partial differential equation of $f(t,x)$ $$\frac{\partial f}{\partial t}=\frac12\frac{\partial^2 f}{\partial x^2}.$$ I would like to express an algebraic function $g$ of the variable $\Big(\frac{\partial f}{\partial t}, \frac{\partial^2 f}{\partial t\partial x}\Big)$ all in the partial derivatives of $x$. That is $$\frac{\partial^2 f}{\partial t\partial x}=\frac12\frac{\partial^3 f}{\partial x^3}.$$ The result should be $$g\Big(\frac{\partial f}{\partial t}, \frac{\partial^2 f}{\partial t\partial x}\Big)=g\Big(\frac12\frac{\partial^2 f}{\partial x^2}, \frac12\frac{\partial^3 f}{\partial x^3}\Big).$$

How can I accomplish this with SageMath?

2018-10-31 21:46:08 +0200 commented answer Symbolic Taylor expansion

Excellent! Is there a way to expand using $\delta t$ directly without going through $h$? Also I would like to generalize this to the second half of my newly edited question. Could you please review my question? Thank you.

2018-10-31 21:42:43 +0200 commented answer Symbolic Taylor expansion

Well, that would be part of the solution. But I want a multiple term expansion of the Taylor series then substituting in the expansion of $\delta x$. The latex command is nice, though. I can use it at the last command to present the result better.

2018-10-31 19:21:24 +0200 asked a question Taylor expansion

I would like to

2018-10-31 02:10:29 +0200 edited answer polynomial list, array

Thanks for the answers posted above. Though not directly resolving my intended question due to the confusing statement of my original post, they made me realize I need to declare the list first, like p = [], just like in Python, then append the polynomials or anything else for that matter, one by one, with say p.append(polynomial).

2018-10-31 02:08:34 +0200 asked a question Symbolic Taylor expansion

I would like to expand the symbol function $f$ as a Taylor series $$\delta f(x)=\delta x\frac{d}{dx}f+\frac12(\delta x)^2\frac{d^2}{dx^2}f+O((\delta x)^3)$$ with $$\delta x = a_1(\delta t)^{\frac12}+a_2(\delta t)+a_3(\delta t)^{\frac32}+O((\delta t)^2)$$ and expand and collect the same power terms of $\delta t$ up to a designated power, say, $\frac32$. $f$ is just a symbol, I just need Mathsage to produce the symbols of derivatives $\frac{d}{dx}$.

How should one set this up?


Inspired by eric_g's answer to this question, I am able to perform the same operation to $f(x,y)$ with $$\delta y = a_1(\delta s)^{\frac12}+a_2(\delta s)+a_3(\delta s)^{\frac32}+O((\delta s)^2)$$. I would like to collect terms according to the powers $dt^{\frac i2}ds^{\frac j2}$ where $i$ and $j$ are nonnegative integers and arranged in the ascending order of $i+j$. I would also like to have the capacity to collect terms according to the order of some other variables, say, $a_1$. I have tried using

g.full_simplify().maxima_methods().collectterms(dt)

for a single variable $dt$. But it does not seem to work well for the fractional power. I do not know if it will work for $dt^{\frac i2}ds^{\frac j2}$.

How can I set this up?

2016-08-27 03:45:34 +0200 received badge  Famous Question (source)
2016-01-04 23:50:30 +0200 received badge  Famous Question (source)
2015-10-29 14:58:52 +0200 received badge  Notable Question (source)
2015-07-13 21:57:51 +0200 received badge  Notable Question (source)
2015-07-13 21:57:51 +0200 received badge  Popular Question (source)
2015-03-27 04:07:47 +0200 marked best answer plot in Octave

To add context as requested by kcrisman, I am using Octave in Cloud.Sagemath.com running scripts in .m files.

How does one plot in Octave? Supposedly the command should be the same as in Matlab, e.g.

x = 1:10; figure, plot(x,x.^2)

However, nothing showed up in the terminal. Please help.

2015-02-27 12:22:00 +0200 received badge  Nice Question (source)