Re: Sage help needed

Apr 20, 2014 2 Replies

Is there a mode setting -- evaluate versus exact mode, or what have you?



I've only used a few math suites, so I can't be much help specifically..



Tim


-- Seven Transistor Labs Electrical Engineering Consultation Website:

formatting link



Help!
>
> I'm trying to learn the Sage mathematics package but with no
> documentation, it's proving almost impossible. Here's an example
> problem, find the mu of a ferrite from its physical parameters and an
> inductance test.
>
> L,mu,N,area,pathlength = var('L mu N area pathlength')
>
> L=20.65e-3
> N=50
> area=11.544
> pathlength=27.63
>
> solve(L == 0.4 * pi * mu * N^2 * (area / pathlength)*1e-8, mu)
>
> Sage produces the mathematically correct but useless answer:
>
> [mu == 9509325/1924/pi]
>
> Instead of the correct AND useful answer
> 1573.2
>
> There is the n() operator that is supposed to return the numerical
> result but if I use the expression
>
> n(mu)
>
> Sage returns
>
> "TypeError: cannot evaluate symbolic expression numerically"
>
> If I try
>
> n(L == 0.4 * pi * mu * N^2 * (area / pathlength)*1e-8, mu)
>
> I get
>
> "ValueError: cannot convert mu to int"
>
> I don't know where to go from here. Not knowing Python probably
> doesn't help anything. Any help is greatly appreciated.
>
> John
> John DeArmond
>
formatting link

>
formatting link

> Tellico Plains, Occupied TN
> See website for email address
>

That's not mathematically correct, it's arithmetically close, but pi is transcendental.

basically you want to get here:

n( 9509325/1924/pi )

I found this:

sage: a=solve(L == 0.4 * pi * mu * N^2 * (area / pathlength)*1e-8, mu) sage: n(a[0].rhs())

1573.23916758559

To get there I used "dir(a)" , "dir(a[0])", and a little guessing.

umop apisdn --- news://freenews.netfront.net/ - complaints: news@netfront.net ---

I'd just as well do it in a spreadsheet (or at worst, a Java Applet), but oh well..

Tim

-- Seven Transistor Labs Electrical Engineering Consultation Website:

formatting link

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required