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.Mon, 28 Sep 2020 08:00:42 +0200Using base 10 exponent of a number as label in a contour plothttps://ask.sagemath.org/question/53631/using-base-10-exponent-of-a-number-as-label-in-a-contour-plot/ I am currently trying to improve the labelling of a contour plot. As contours I'm only using negative powers of ten, so I hope to have a simple LaTeX label of the form, say, 10^{-23}. My starting point was one of the examples at the help page for contour_plot (here was the link to the sage documentation). After various failed attempts with log(x, 10), I found in the question "Integer types and log()" (that would be question id(?) 28679/integer-types-and-log) an example using valuation(x,10). However, the results seem odd. Below the slightly simplified thing I try to plot.
var('x y')
rp = 6.77048070412999e-10*(x + sqrt(x^2-y^2*x^2))
sigma0 = 1.44008750449331e-18*(3*x + sqrt(9*x^2 - 8*y^2*x^2))^4/(8*(3*x^2 - 2*y^2*x^2 + x*sqrt(9*x^2 - 8*y^2*x^2)))
f(x,y) = (1.12469227142351e-70*y*x^2/(rp)^6*exp(-(rp)^2/(sqrt(y)*x*0.169262017603250))-1.65389403372211e-162*(sqrt(x^2-y*x^2))^3*sigma0*(x-2*sqrt(x^2-y*x^2))/(rp)^10)
contour_plot(f(x,y), (x,0,100), (y,0,1), contours=[0,1e-25,1e-24,1e-23,1e-22,1e-21,1e-20,1e-19],aspect_ratio='automatic',labels=True, label_fmt=lambda x: r'''$10^{-%s}$'''%(valuation(1/x,10)), fill=False)
If I do this, I get 10^{-0} for several contours.
So, I checked, what valuation does to the numbers:
print(valuation(1/(1e-19),10))
print(valuation(1/(1e-20),10))
print(valuation(1/(1e-21),10))
print(valuation(1/(1e-22),10))
print(valuation(1/(1e-23),10))
yielding
19
20
0
22
0
If I'm using something like
label_fmt=lambda x: r'''$10^{-%s}$'''%(log(1/x,10))
instead, I get only the message "Graphics object consisting of 1 graphics primitive", and
label_fmt=lambda x: r'''$10^{-%s}$'''%(log(Integer(1/x),10))
yields another plot with odd labels - which have the odd behaviour at the same exponents as the example with "valuation", but I don't know why.
I'm currently doing this mostly in a jupyter notebook on Windows 10 with Sage 9.1.
Am I misunderstanding the use of "valuation" or log(x,10) in this case? Did I run into a bug? How can I get the exponents I'm after?Wraith-of-SethMon, 28 Sep 2020 08:00:42 +0200https://ask.sagemath.org/question/53631/Law of logs false for symbols but true for numbershttps://ask.sagemath.org/question/53024/law-of-logs-false-for-symbols-but-true-for-numbers/Why do I get False for the additive law of logs for symbols, but True for numbers?
var('a b')
print(bool(log(a)+log(b)==log(a*b)))
print(bool(log(5)+log(10)==log(5*10)))
False
TruecybervigilanteSat, 15 Aug 2020 07:15:55 +0200https://ask.sagemath.org/question/53024/solve() does not solvehttps://ask.sagemath.org/question/50421/solve-does-not-solve/The output of this system is [] after waiting 10 mins. What's the problem here?
var('a2,b2')
solve([
log(10,a2) + log(10,b2) * 435 == 50.88,
log(10,a2) * 435 + log(10,b2) * 8555 == 979.15], a2,b2)Alex89Sun, 29 Mar 2020 19:24:47 +0200https://ask.sagemath.org/question/50421/Log scale in vector fieldhttps://ask.sagemath.org/question/33889/log-scale-in-vector-field/Is there a way to plot a 2D vector field with log scale in the x-axix? I was using plot_vector_field, but I can't find a way to use log with that.vitorThu, 23 Jun 2016 03:36:07 +0200https://ask.sagemath.org/question/33889/Integer types and log()https://ask.sagemath.org/question/28679/integer-types-and-log/I am working with a bunch of lists whose lengths are all powers of 2. I'd like to be able to extract the power by taking the base-2 log of the length. However, Sage wasn't able to simplify an expression like log(len(L),2), because apparently len() returns the wrong kind of integer:
sage: A=list(range(8))
sage: len(A)
8
sage: log(len(A),2)
log(8)/log(2)
sage: log(8,2)
3
sage: type(len(A))
<type 'int'>
sage: type(8)
<type 'sage.rings.integer.Integer'>
sage: log(Integer(len(A)),2)
3
This is the first math function I've come across that seems to care about the distinction between these two kinds of integers, and it would be nice if it didn't, since it took me quite a while to figure out why Sage wouldn't simplify an expression like log(len(A),2).Jeremy MartinTue, 21 Jul 2015 16:57:56 +0200https://ask.sagemath.org/question/28679/[log discret logarithm] implantation index calculus algorithmhttps://ask.sagemath.org/question/9938/log-discret-logarithm-implantation-index-calculus-algorithm/Hello everybody,
I have a problem to implement with sage the index calculs algorithm in order to resolve the discret log 's problem.
I can create a system of algebra equation, but I can't compute the same modulo for each line
, I have ever the theorem of Chinese rest, but unsuccessfull !
Could you help me please ?
Vistrate
vistrateSat, 23 Mar 2013 11:47:20 +0100https://ask.sagemath.org/question/9938/How to treat with logarithm numerically when it becomes negative?https://ask.sagemath.org/question/9903/how-to-treat-with-logarithm-numerically-when-it-becomes-negative/I have a term log(f(x)) in my equations which I am trying to solve them numerically. But the solver does not solve, perhaps when the argument of the logarithm becomes negative. What should I write in the program when f(x)<0 in the loop in order not to loose the iteration?
ThankselaTue, 12 Mar 2013 10:38:41 +0100https://ask.sagemath.org/question/9903/log base 10https://ask.sagemath.org/question/8525/log-base-10/Is there a built-in way to use a log with base other than e? The log documentation doesn't show any example (I thought log(10,x) was what I wanted for a while but it's actually different than what one might expect). JasonThu, 01 Dec 2011 12:46:54 +0100https://ask.sagemath.org/question/8525/Calculating Integralhttps://ask.sagemath.org/question/8048/calculating-integral/f(x) = e**(-x) * log(x+1);<br>
uu = integral(f, (x, 0, oo));<br>
uu.n(digits=18)<br>
why this dont work?SagudWed, 06 Apr 2011 18:49:23 +0200https://ask.sagemath.org/question/8048/integral of 1/x, tan xhttps://ask.sagemath.org/question/8004/integral-of-1x-tan-x/why integral ($ $$1/x$, $x$) returns $log(x)$? Shouldn't it return $log(|x|)$. Similarly,
integral$(tan(x),x)$ returns $log(sec(x))$ shouldn't it return $log(|sec(x)|)$.
Can anyone explain?
After previous post, I dig a little bit and find:
sage: equation=integral(1/x+x,x).real()
sage: equation
1/2*real_part(x)^2 - 1/2*imag_part(x)^2 + log(abs(x))
sage:
Now, anyway to set real_part(x)=x and imag_part(x)=0 in "eq" and get the resultant "eq"?
More>>
sage: integral(1/(x^3-1),x).real()
-1/3*sqrt(3)*real_part(arctan(1/3*(2*x + 1)*sqrt(3))) + 1/3*log(abs(x - 1)) - 1/6*log(abs(x^2 + x + 1))
Everything is fine in the above computation except the word "real_part". Anyway to get rid of that?ShuWed, 16 Mar 2011 11:13:20 +0100https://ask.sagemath.org/question/8004/How does sage deal with choosing branches? Examples?https://ask.sagemath.org/question/7710/how-does-sage-deal-with-choosing-branches-examples/[http://en.wikipedia.org/wiki/Principal\_branch][1]
[http://en.wikipedia.org/wiki/Exponentiation#Failure\_of\_power\_and\_logarithm\_identities][2]
[1]: http://en.wikipedia.org/wiki/Principal_branch
[2]: http://en.wikipedia.org/wiki/Exponentiation#Failure_of_power_and_logarithm_identitiesccanoncSat, 25 Sep 2010 15:34:50 +0200https://ask.sagemath.org/question/7710/