Ask Your Question

erikblue's profile - activity

2023-07-27 19:40:54 +0200 received badge  Notable Question (source)
2023-07-27 19:40:54 +0200 received badge  Popular Question (source)
2021-11-09 12:24:13 +0200 received badge  Popular Question (source)
2020-01-31 18:36:36 +0200 commented answer Simple question on displaying summation

Ok thanks for the answer. I guess if I want to display it in pretty summation notation I will need to use LaTeX. Glad I wasn't missing anything.

2020-01-31 02:01:14 +0200 asked a question Simple question on displaying summation

Hi,

I'm defining a few summation functions for displaying and evaluating later, but I don't understand how to do it.

So, I'm looking at the basic Sage Quick Reference and I see under Arithmetic: sum(f(i) for i in (k..n))

But when I try to make it symbolic to show, like something simple like this:

var('i,n')
f(n)=sum(i for i in (0..n))
show(f)

But then I get

TypeError: unable to simplify to float approximation

Which makes me think its trying to evaluate the sum rather than make it a symbolic expression. Then I ran across "symbolic_sum" somewhere, but I can't find any documentation about it now...

Any suggestions?

Erik

2020-01-30 03:06:46 +0200 answered a question Working with units

Ok, so I'm doing fine with pint with one exception: When I define a symbolic expression and then try to evaluate that expression using variables that have units. For example, I define a symbolic expression:

Vres(Vref,RES)=2*Vref/2^RES

And I try to evaluate it using a pint variable (with units I defined):

Vres(5*u.V, 20)

I get a type error:

TypeError: no canonical coercion from <class 'pint.quantity.build_quantity_class.<locals>.Quantity'> to Callable function ring with arguments (Vref, RES)

I guess this makes sense because how would the symbolic expression class know what to do with a pint type variable? Which brings me back to the built-in units with SageMath. With built-in "units" class, symbolic expressions are fine, but I can't add my own custom units so I'm stuck... I desperately need units like V, nV, uV, mV, and nV/sqrt(Hz).

2020-01-29 22:41:35 +0200 commented answer Working with units

Ok, so I'm doing fine with pint with one exception: When I define a symbolic expression and then try to evaluate that expression using variables that have units. For example, I define a symbolic expression:

Vres(Vref,RES)=2*Vref/2^RES

And I try to evaluate it using a pint variable (with units I defined):

Vres(5*u.V, 20)

I get a type error:

TypeError: no canonical coercion from <class 'pint.quantity.build_quantity_class.<locals>.Quantity'> to Callable function ring with arguments (Vref, RES)

I guess this makes sense because how would the symbolic expression class know what to do with a pint type variable? Any ideas?

2020-01-22 08:34:59 +0200 received badge  Scholar (source)
2020-01-17 01:23:49 +0200 received badge  Student (source)
2020-01-12 18:39:37 +0200 asked a question Working with units

Hi,

I am just getting started with sage. I'm an electrical engineer. One thing that was really nice about Mathcad was letting me know if my units were messed up. I see there are electrical units types, like "units.electrical_potential.volt" but I'm struggling to see how to use it in a real application.

For example, a resistor, do I do something like this for 220 ohm resistor?

R = 220 * units.resistance.ohms

And what I'd really like to do is then define a voltage:

V = 1*units.electrical_potential.volt

And then be able to just go like this to get the current through the resistor:

V/R

Which would output something like this:

0.00455 * units.current.amp

Or better yet, just:

4.55mA

I don't mind building my own class to achieve this functionality. I also need to create my own units, for example noise spectral density such as V*sqrt(Hz).

Anyways, I really like what I see with Sage so far, I tried to use PTC Mathcad a while back and was pulling my hair out... Sage seems super intuitive and flexible, just being able to type things out in the notebook is great.

Thank you!

Erik