Python在电路课程中的应用

1 需求

课程中有大量的计算,电路方程、复数计算,之前都是用的MATLAB online,可现在要过期了,只能更换平台。

2 工具

https://www.online-python.com/

Python3 在线工具 | 菜鸟工具 (runoob.com)

3 Sinusoid 章节

涉及到复数计算,相关函数见 cmath --- 关于复数的数学函数 --- Python 3.11.5 文档

3.1 复数 1

Code

python 复制代码
import cmath,math
a=complex(6*math.cos(30/180*math.pi),6*math.sin(30/180*math.pi)) # transfer to randian
a=cmath.rect(6,30/180*math.pi)
b=complex(5,-3)
c=complex(2,4)
d=(a+b)/c
print(f' the result is {d} ')
print(f' real  {d.real}, img  {d.imag}')
 
print(f'in polar {abs(d)}   {cmath.phase(d)/math.pi*180} ')

Result:

the result is (1.0196152422706632 -2.0392304845413265j)

real 1.0196152422706632, img -2.0392304845413265

in polar 2.27992899261212 -63.43494882292201

3.2 复数2

Code

python 复制代码
import cmath,math

a=cmath.rect(40,50/180*math.pi)
b=cmath.rect(20,-30/180*math.pi)

c=cmath.sqrt(a+b)
print(f' a is {a} , b is {b}, sqrt (a+b) is {c} or  amplitude is {abs(c)} and with angle {cmath.phase(c)/math.pi*180}')

Result

a is (25.711504387461574+30.64177772475912j) , b is (17.320508075688775-9.999999999999998j), sqrt (a+b) is (6.7364198203407835+1.5321029771950059j) or amplitude is 6.9 08450732878534 and with angle 12.813149787630694

** Process exited - Return Code: 0 **

Press Enter to exit terminal

相关推荐
鬼手点金5 分钟前
opencode-crawl4ai使用建议
java·开发语言·人工智能·python·机器学习
海天一色y13 分钟前
深入理解对偶单纯形法:原理推导与 Python/MATLAB 编程实现
python·matlab·最优化算法·对偶单纯形法
专业程序开发源19 分钟前
springboot校园志愿者管理系统28562-计算机课程设计、毕业设计
java·spring boot·后端·python·django·php·课程设计
计算机毕业编程指导师31 分钟前
计算机毕设怎么做?Python+Hadoop的跨平台消费者评论情感分析与数据可视化系统实战 源码 毕业设计 选题推荐 毕设选题 数据分析
大数据·hadoop·python·计算机·spark·课程设计·消费者评论
余槐i38 分钟前
WAL 下写并发仍是 1:SQLite 单写者模型实测与绕开方案
数据库·python·性能优化·sqlite·wal
怕浪猫9 小时前
RAG 面试 6 连问,从原理到优化全部覆盖
python·算法·面试
高洁019 小时前
具身智能中的世界模型训练
人工智能·python·深度学习·机器学习·transformer
无线通信科研笔记9 小时前
IEEE TVT 2026 论文精读与完整复现|相位误差如何重塑近场 RIS 的幅相响应
论文阅读·人工智能·python·算法·论文笔记
朝朝辞暮i10 小时前
VLA 系统学习第 1 课:VLA 到底在干什么?
人工智能·python·计算机视觉·vla
2601_9628857210 小时前
如何用 Python 自动识别股票的支撑位与压力位?
开发语言·python