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, 08 Jan 2022 09:14:05 +0100mpmath not working with sage equationshttps://ask.sagemath.org/question/60577/mpmath-not-working-with-sage-equations/I'm trying to get a numerical solution to a problem similar to the one discussed in [this old post](https://ask.sagemath.org/question/8546/numerical-solution-of-a-system-of-non-linear-equations/) but somewhat messier -- there are decimals and the variables to solve for are in an exponent. I ran the example given in the old post, with som syntactical updating and using `import mpmath as mp` and everything works exactly as shown. But when I switch to my problem, I get a "TypeError: cannot evaluate symbolic expression numerically" error. What's the difference between the two cases and what should I do? I've tried changing ^ to ** and restarting the kernel.
Here's my code:
import mpmath as mp
var("Vmax,Km")
eq0 = 101/4563863823**(32.4*Vmax/Km) - 71.85 == 0
eq1 = 96.3/85080567**(2.4*Vmax/Km) - 74.25 == 0
f = [lambda Vmax,Km: eq0.lhs().subs(Vmax=RR(Vmax), Km=RR(Km)),
lambda Vmax,Km: eq1.lhs().subs(Vmax=RR(Vmax), b=RR(Km))]
found_root = mp.findroot(f, (2, 2))
found_root = Matrix(RR, found_root.tolist())
print(found_root)
fa,fb = found_root.list()
#Check results
print(eq0.subs(Vmax=fa,Km=fb))
print(eq1.subs(Vmax=fa,Km=fb))
jaiaSat, 08 Jan 2022 09:14:05 +0100https://ask.sagemath.org/question/60577/Why do computations with pi default to symbolic?https://ask.sagemath.org/question/47217/why-do-computations-with-pi-default-to-symbolic/Hello, Sage community,
It is known fact that SageMath uses symbolic computations by default. For example,
sqrt(8)
returns `2*sqrt(2)`. But it is also known that this behavior can be easily changed using decimals, like in the following case:
sqrt(8.0)
which returns `2.82842712474619`.
However, this technique doesn't seem to work with symbolic constants like `pi` and `e`. For example,
80 / pi
returns the expected `80/pi`, but
80.0 / pi
returns `80.0000000000000/pi` instead of the numerical value `25.4647908947033`.
I was wondering why is this the case.
Thanks in advance for your answers!dsejasFri, 19 Jul 2019 23:58:44 +0200https://ask.sagemath.org/question/47217/Symbolic to numerical arrayhttps://ask.sagemath.org/question/38811/symbolic-to-numerical-array/ I would like to get a number-valued array from a symbolic-valued array, for example:
( sin(1), cos(1), pi/4) to ( sin(1).n() , cos(1).n() , pi/4.n() )
WITHOUT having to convert one component at a time, but directly transforming the array. When I write
( sin(1), cos(1), pi/4 ).n()
I get 'Error'. I would greatly appreciate any help :)daniel-Ri-1011101Wed, 13 Sep 2017 16:56:12 +0200https://ask.sagemath.org/question/38811/