ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 27 Jun 2020 14:50:08 +0200implicitly defining a sequence of variableshttps://ask.sagemath.org/question/8181/implicitly-defining-a-sequence-of-variables/To define a general polynomial in Maple one writes
p := sum(a[i]*x^i,i=0..n);
and gets $p = \sum _{i=0}^{n}a_{{i}}{x}^{i}$.
So the "a[i]" are implicitly understood as variables, and their number (n) is also a variable. Or perhaps "a" is implicitly understood as a sequence of variables? I don't know what happens behind the scenes here, but it is very usefull.
Trying to accomplish this in sage I reached
sage: var('x,i,n')
(x, i, n)
sage: a = function('a')
sage: p = sum(a(i)*x^i,i,0,n);p
sum(x^i*a(i), i, 0, n)
Is this the right way? It doesn't behave as nice as in maple. Trying series, taylor, and diff only taylor works correctly:
sage: p.series(x==0,3)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
....
RuntimeError: power::eval(): division by zero
sage: p.taylor(x,0,3)
x^3*a(3) + x^2*a(2) + x*a(1) + a(0)
sage: p.diff(x)
i*x^(i - 1)*a(i)*D[0](sum)(x^i*a(i), i, 0, n)
In Maple they all give good results.
Am I going at this the right way? Is there a way to implicitly define variables as in Maple?
parzanWed, 22 Jun 2011 06:48:29 +0200https://ask.sagemath.org/question/8181/How do I differentiate an implicit function in sagemath?https://ask.sagemath.org/question/52235/how-do-i-differentiate-an-implicit-function-in-sagemath/ I'm trying to differentiate an implicit expression
$x e^{y} = x -y$
This is my sagemath code
x = var('x')
f(x,y)= x*e**y - x + y
show(diff(f))
Sagemath Answer is
$\left( x, y \right) \ {\mapsto} \ \left(e^{y} - 1,\,x e^{y} + 1\right)$
But the actual answer is
$\frac{1 - e^{y}}{x e^{y} + 1}$
How do I get the actual answer using sagemath?loloraSat, 27 Jun 2020 14:50:08 +0200https://ask.sagemath.org/question/52235/how do I differentiate an implicit equationhttps://ask.sagemath.org/question/52229/how-do-i-differentiate-an-implicit-equation/I'm trying to differentiate an implicit expression
$x e^{y} = x -y$
This is my sagemath code
x = var('x')
f(x,y)= x*e**y - x + y
show(diff(f))
Sagemath Answer is
$\left( x, y \right) \ {\mapsto} \ \left(e^{y} - 1,\,x e^{y} + 1\right)$
But the actual answer is
$\frac{1 - e^{y}}{x e^{y} + 1}$
How do I get the actual answer using sagemath?loloraFri, 26 Jun 2020 22:49:56 +0200https://ask.sagemath.org/question/52229/Variables r and R are gobbledhttps://ask.sagemath.org/question/52168/variables-r-and-r-are-gobbled/If implicit multiplication is not active, something like `4y^2` should raise an error. This is what actually happens:
sage: var("y"); 4y^2
File "<ipython-input-22-25bcbc82148c>", line 1
var("y"); 4y**Integer(2)
^
SyntaxError: invalid syntax
If we replace `y` by a different variable or consider a similar expression, we also get an error... except if the variable is `r` or `R`. For example,
sage: var("r, R"); 4r^2, 3R + 5r + 2R^3
(16, 16)
Surprisingly, there is no error. Variables `r` and `R` seem to be gobbled, so that SageMath parses `4r^2` as `4**Integer(2)` and `3R + 5r + 2R^3` as `3 + 5 + 2**Integer(3)`. Why? Is this a bug?JuanjoTue, 23 Jun 2020 04:41:20 +0200https://ask.sagemath.org/question/52168/Why does implicit multiplication not work in the Sage Cell Server?https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/Hello, Sage Community!
Is there any reason for `implicit_multiplication(True)` not having any effect in SageCell? Is there any way of solving this?
Thanks in advance for your answers! dsejasWed, 17 Jun 2020 22:37:41 +0200https://ask.sagemath.org/question/52060/evaluating derivative of implicit functionhttps://ask.sagemath.org/question/46026/evaluating-derivative-of-implicit-function/ I am trying to evaluate the derivative of an implicitly defined function
rho = function('rho',u)
u_z_equation = u*z^3 - u*z^2 - z^3 + z^2 - 2*z + 1
implicit = u_z_equation(z=rho)
rho_1 = solve(implicit(u=1),rho(1))[0]
print rho_1
d_rho = solve(diff(implicit,u),diff(rho))[0]
print d_rho(u=1)
But I do not know how to substitute the value I found for rho(1) into the expression for the derivativebrettpimFri, 05 Apr 2019 22:28:44 +0200https://ask.sagemath.org/question/46026/False implicit plothttps://ask.sagemath.org/question/45627/false-implicit-plot/Hello
I write in SAGE
implicit_plot(y==1/2, (-1,1),(-1,1))
and it returns the graph of the line x=1/2. Why? creyesm1992Sun, 03 Mar 2019 18:38:12 +0100https://ask.sagemath.org/question/45627/implicit_plot plot of a listhttps://ask.sagemath.org/question/45196/implicit_plot-plot-of-a-list/ Hello,
On Sage 8.5, Release Date: 2018-12-22, I am doing
`var('x,y')`
`F1 =plot([k/x for k in [-5..5]], (-5, 5), ymin=-5, ymax = 5, detect_poles=True, color="red")`
`F2= implicit_plot([y^2 - x^2 -c for c in [-5..5]], (x,-5,5), (y,-5,5))`
to obtain two families of orthogonal curves. While the first family is ok, there seems to be a problem with the second one.
I can circunvent my problem by doing a lis of plots (instead of the plot of a list), as follows :
`[implicit_plot(y^2 - x^2 -c ==0, (x,-5,5), (y,-5,5), color="blue" ) for c in [-5..5]]`
I was expecting that `plot(...)` and `implicit_plot(...)` would beheave in the same manner in this situation. Why this is not the case? Am I missing something in the syntax?
Regards,
JC
JCSun, 27 Jan 2019 04:47:23 +0100https://ask.sagemath.org/question/45196/solve system of non-linear implicit equations numericallyhttps://ask.sagemath.org/question/10269/solve-system-of-non-linear-implicit-equations-numerically/I am attempting to solve for a solution of a system of two non-linear implicit equations using the following code:
x = var('x')
y = var('y')
P = [(-1,-5), (1,-5), (-5,0), (5,5)]
# Defining the function
d = sum([sqrt( (x-p[0])^2 + (y-p[1])^2 ) for p in P])
show(d)
# Differentiate with respect to x and y
eqx = d.diff(x)
eqy = d.diff(y)
# Plot both implicit curves
g1 = implicit_plot( eqx==0, (x,-10,10), (y,-10,10), color="blue" )
g2 = implicit_plot( eqy==0, (x,-10,10), (y,-10,10), color="red" )
show(g1 + g2) # note that you can clearly see an intersection of the two curves
# Solve for the solution
print("Solving...")
sol = solve([eqx==0, eqy==0], x, y) # this gets stuck or takes a long time
show(sol)
Everything runs, up to the point of the solve function, which continues to run for what appears to be indefinitely. The code show(g1 + g2) shows a graph that clearly shows there exists an intersection for both curves. I tried to use to_poly_solve=True without success. I do not mind an approximate solution, however I was unable to find a numeric solver for a system such as this (find_root afaik only works on one variable) that will work.
Does there exist a numeric solver which is capable of solving a system of this form? What other alternatives are there?
Thanks,
menturimenturi628Fri, 21 Jun 2013 18:06:50 +0200https://ask.sagemath.org/question/10269/solution for implicit function with boundary conditionhttps://ask.sagemath.org/question/34335/solution-for-implicit-function-with-boundary-condition/ Hello everyone
I have a equation of
$$ x \sin(\theta_0)+y \cos(\theta_0)+Cy_0-a \sin(((x \cos(\theta_0)-y \sin(\theta_0))+Cx_0)/Wavelength 2 \pi) == 0$$
which is the graph of
$$a \sin(x/Wavelength 2 \pi)$$
translate $Cx_0, Cy_0$ and turn $\theta$ degree
Now I want to find the value of y for every x
and the boundary condition is -5<x<5 and -2<y<2
I only need numerical solution
So I write(for example)
xxx=1
solve([xxx*sin(theta0)+yy*cos(theta0)+Cy0-a*sin(((xxx*cos(theta0)-yy*sin(theta0))+Cx0)/Wavelength*2*pi)==0],yy)
but it only give me
yy == -1591171550/11651589*sin(-8742223/40728696*pi + 1674841/89990759*pi*yy) - 2736327944741683/32059067495364
This is not what I need
How can I solve it?
randy19962Fri, 05 Aug 2016 14:12:27 +0200https://ask.sagemath.org/question/34335/Maximize the integral of an implicit relation with two parametershttps://ask.sagemath.org/question/25270/maximize-the-integral-of-an-implicit-relation-with-two-parameters/ Suppose we have an equation:
$${(r\cos{(t)}+u})^{2}+{(-(r\sin{(t)}+v)^3+1)}^{\frac{2}{3}}=1$$
Where $x=r\cos{t}$ and $y=r\sin{t}$
The graph of this implicit relation has two regions, where one part is above the x-axis, and the other part is below the x-axis.
Suppose we're are trying to find the area of the relation above the x-axis, between the x-values ${0}\le{x}\le{2\pi}$. How can one solve for the values of u and v that can give the highest area for this equation that's is above the x-axis, so that u and v as point (u,v) is still inside the implicit relation $$(1-x^2)^3=(1-y^3)$$.
Note: The blue stripes should stop at $2\pi$, and if the equation has regions that are "UNDEFINED", try to ignore it.
**I MADE EDITS!**
Krishnan ArbujaSun, 14 Dec 2014 20:33:04 +0100https://ask.sagemath.org/question/25270/obtain explicit solutions from "solve"https://ask.sagemath.org/question/10761/obtain-explicit-solutions-from-solve/I tried to use "solve" but, in the output, the variable of my interest is left implicit
[x3 == 1/6780*(27360*a + 9618*t - sqrt(202500*t^2*x3^2 + 1464480000*a^2 + 541225440*a*t + 17122609*t^2 + 22500*(528*a*t + 7*t^2)*x3 - 26040*sqrt(324*t^2*x3^2 + 20736*a^2 + 2016*a*t + 49*t^2 + 36*(528*a*t + 7*t^2)*x3)*(240*a + 13*t)) - 25*sqrt(324*t^2*x3^2 + 20736*a^2 + 2016*a*t + 49*t^2 + 36*(528*a*t + 7*t^2)*x3))/t, x3 == 1/6780*(27360*a + 9618*t + sqrt(202500*t^2*x3^2 + 1464480000*a^2 + 541225440*a*t + 17122609*t^2 + 22500*(528*a*t + 7*t^2)*x3 - 26040*sqrt(324*t^2*x3^2 + 20736*a^2 + 2016*a*t + 49*t^2 + 36*(528*a*t + 7*t^2)*x3)*(240*a + 13*t)) - 25*sqrt(324*t^2*x3^2 + 20736*a^2 + 2016*a*t + 49*t^2 + 36*(528*a*t + 7*t^2)*x3))/t]
Someone can help me? Thank you,
Carlo
carlo.bottaiThu, 21 Nov 2013 17:01:04 +0100https://ask.sagemath.org/question/10761/find best fit for implicit equation.https://ask.sagemath.org/question/10588/find-best-fit-for-implicit-equation/Hi,
I have to fit numerical data to an analytic model in the same way that is done by the find_fit command of sage.
The problem is that my model is an implicit function which can't be simplified. It's the solution of a differential equation and it's quite messy.
Any ideas about how could I solve this with sage.ZardozThu, 03 Oct 2013 19:35:34 +0200https://ask.sagemath.org/question/10588/Plot a circle, by utilizing an equation solved for xhttps://ask.sagemath.org/question/10483/plot-a-circle-by-utilizing-an-equation-solved-for-x/The following code is an example of plotting the equation: x = y^2-3*x-5*y+7, i.e. an equation solved for x:
var('y')
f = y^2-3*x-5*y+7
Yax = x
Xax = y
p1= implicit_plot(f, (x,-4, 4), (y,-2, 6))
p3= implicit_plot(Yax, (x,-4, 4), (y,-2, 6),color='black')
p4= implicit_plot(Xax, (x,-4, 4), (y,-2, 6),color='black')
p0= p1+p3+p4
show(p0)
According to the author, he solved the following equation in terms of x: x^2+y^2 = 25
He got the following: x = sqrt(25 - y^25) and x = -sqrt(25-y^2), i.e. ± sqrt(25 - y^25).
According to him, he plotted the 2 separate results to obtain a circle plot/graph.
How can I generate such an output on Sage 5.9?
The following was my best attempt, but I received no output for the plot of: sqrt(25-y^2):
var('y')
f = sqrt(25-y^2)
Yax = x
Xax = y
p1= implicit_plot(f, (x,-50, 50), (y,-50, 50))
p3= implicit_plot(Yax, (x,-50, 50), (y,-50, 50), color='black')
p4= implicit_plot(Xax, (x,-50, 50), (y,-50, 50), color='black')
p0= p1+p3+p4
show(p0)bxdinThu, 29 Aug 2013 00:40:07 +0200https://ask.sagemath.org/question/10483/Implicit differentiation displays extraneous x variable.https://ask.sagemath.org/question/10393/implicit-differentiation-displays-extraneous-x-variable/The problem is, given `y = 9*x^(1/2) - 2*y^(3/5)`, find dy/dx
The answer is supposed to be `dy/dx = ( 45*y^(2/5) ) / ( 10*x^(1/2)*y^(2/5)+12*x^(1/2) )`
When I enter the following syntax, there is an extraneous character, (x), displayed:
y=function('y',x)
temp=diff(9*x^(1/2) - 2*y^(3/5) - y)
solve (temp,diff(y))
show(solve (temp,diff(y)))
Is it possible to display the answer without showing (x)?
bxdinSun, 28 Jul 2013 10:34:47 +0200https://ask.sagemath.org/question/10393/How to solve an implicit differential equation numerically?https://ask.sagemath.org/question/9506/how-to-solve-an-implicit-differential-equation-numerically/I tried Mathematica for this, but didn't see how to do it.
Is it possible to solve an equation of the following kind?
diff(R(t),t) == C1*(C2 - C3*1/R(t))*(1/R(t) + 1/sqrt(C4*t))
where t is a variable, R(t) is a function of t and C1 to C4 are constants
Any help would be appreciated.
clenzTue, 06 Nov 2012 11:47:43 +0100https://ask.sagemath.org/question/9506/basic algebra with several variables-why won't it work?https://ask.sagemath.org/question/8317/basic-algebra-with-several-variables-why-wont-it-work/Hi,
I'm trying to use Sage-Notebook as a basic calculator and want to do some basic algebra for two variables. However, it keeps giving me syntax error messages when I type in the below. What am I doing wrong?
x, y = var('x, y')
solve([20*(6400-x-2y)==0, 80*(3200-x-y)==0], x, y)
Traceback (click to the left of this block for traceback)
...
SyntaxError: invalid syntax
Thank you!HunMon, 26 Sep 2011 19:12:19 +0200https://ask.sagemath.org/question/8317/Is it possible to get implicitly multiplied output?https://ask.sagemath.org/question/7609/is-it-possible-to-get-implicitly-multiplied-output/With `implicit_multiplication(True)`, we can enter expressions using spaces instead of `*` to separate multiplied subexpressions:
`sage: var('x, y, z')
sage: implicit_multiplication(True)
sage: 3 x^4 y + 2 z sin(x z 3 y) - 3 y^2
3*x^4*y - 3*y^2 + 2*z*sin(3*x*y*z)
`
This works similarly for polynomials.
Is it possible to set (or implement practically) an option that automatically postparses output to use implicit multiplication? For example,
`
sage: R.<a,b,c> = QQ[]; R
Multivariate Polynomial Ring in a, b, c over Rational Field
sage: implicit_multiplication_output(True)
sage: R.random_element()
1/7 a b - 1/4 a c - c^2 + c
`
Mitesh PatelSun, 22 Aug 2010 05:39:55 +0200https://ask.sagemath.org/question/7609/