-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5-1Eigenvalue Methods.Rmd
More file actions
70 lines (45 loc) · 1.46 KB
/
5-1Eigenvalue Methods.Rmd
File metadata and controls
70 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "5-1Eigenvalue Methods"
author: "Hao Li"
date: "10/01/2019"
output:
pdf_document: default
html_document: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
#Note:
This R repository is for demonstration of algorithms involved in the book
Mathematical Modeling (4th Edition) written by Prof. Mark. M. Meerschaert
Use yacas() function in R to call Yacas interface in R.
The PrettyForm() function in Yacas helps print more intuitive math expressions.
```{r cars}
#This R repository is for demonstration of algorithms involved in the book
#Mathematical Modeling (4th Edition) written by Prof. Mark. M. Meerschaert
#coded, edited and tested by Hao Li during Dec. 2018 - Jan. 2019.
#Exp5-1 Eigenvalue Methods
#Clear variables
#rm(list = ls())
library(Ryacas)
#x1 = Sym('x1');x2 = Sym('x2')
yac("f1:=(10/100)*x1-((10/100)/10000)*x1^2-((5/100)/10000)*x1*x2")
yac("f2:=(25/100)*x2-((25/100)/6000)*x2^2-((25/200)/6000)*x1*x2")
yac("df1dx1:=D(x1) f1")
yac("df1dx2:=D(x2) f1")
yac("df2dx1:=D(x1) f2")
yac("df2dx2:=D(x2) f2")
yac("A:={{df1dx1,df1dx2},{df2dx1,df2dx2}}")
yac('PrettyForm(A)')
yac("PrettyForm(S)")
yac("B:=Subst(x1,28000/3)A")
yac("B:=Subst(x2,4000/3)B")
yac('PrettyForm(B)')
yac('E:=CharacteristicEquation(B,x)')
yac('E:=Simplify(E)')
yac('PrettyForm(E)')
yac('TexForm(E)')
yac('lambda:=Solve(E==0,x)')
yac('PrettyForm(lambda)')
```