Ask Your Question
0

Solving simultaneous equations

asked 2015-01-08 21:23:12 +0200

samric gravatar image

I am new to Sagemath and I am trying to figure out how to solve two equations representing a circuit composed of a diode and a resistor. Here's what I entered into Sage :

id, vd = var('id vd')
eq1 = id == 10*10^(-12) * (e^(vd/0.039)-1)
eq2 = id == (10/500) - (vd/500)
solve([eq1,eq2],id,vd)

However, this evaluates to :

[id == -1/500*vd + 1/50, id == 1/100000000000*e^(25.64102564102564*vd) -1/100000000000]

What I would like to get is the numerical values of both id and vd (respectively the current and voltage drop across the diode), i.e. approximately 18mA and 0,8V. This simple circuit was taken from "Electronic Devices and Circuit Theory' and was originally solved using Mathcad, but I can't figure out how to do this in Sagemath.

Thanks for the help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-01-08 21:59:07 +0200

kcrisman gravatar image

You are looking for a numerical solution; solve wants to give you exact solutions, and cannot solve this system - even doing it "by hand" gives

sage: solve(eq1.subs(vd=solve(eq2,vd)[0].rhs()),id)
[id == 1/100000000000*e^(-500000/39*id + 10000/39) - 1/100000000000]

To find a root between two endpoints, use something like

sage: find_root(id == 1/100000000000*e^(-500000/39*id + 10000/39) - 1/100000000000,0,10)
0.01833629407646303

Good luck!

edit flag offensive delete link more

Comments

Thanks for the help. Now let's suppose I had i equations (i > 2) and I wanted to get the numerical solutions for their i variables, would it be possible to do it without having to substitute those variable individually into the i equations?

To put it another way, is there a quick and easy way to get sage to resolve numerically a set of equation the way Mathcad would do it, i.e. :

Given
  <set of equation>
  ....
Find(<variable numerical values>)
samric gravatar imagesamric ( 2015-01-08 22:32:13 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-01-08 21:23:12 +0200

Seen: 273 times

Last updated: Jan 08 '15