中的R与绘制绝对值

中的R与绘制绝对值

问题描述:

我不知道是否有绘制以下两个方程中的R中的R与绘制绝对值

x和y一个简单的方法是变量,其余为已知的参数。

enter image description here

enter image description here

当X为维度的向量n然后

enter image description here

enter image description here

+0

你想要做什么?你想找到解决方程式的'(x,y)',还是想在图形中可视化? –

+0

我需要可视化图形。 – Nile

这是一个数学问题而不是编程。一点计算会帮助编程任务变得更容易。

首先,为了简单起见,假定c_1c_2等于零。我们可以通过移动轴来轻松恢复原始比例。然后,矩阵计算可以写成如下。

enter image description here

现在让z = ax + byw = cx + dy。然后,绝对值指标的第一个方程就可以写成:

enter image description here

从这个等式,假设伽马是肯定的,你可以想像zw如下。

enter image description here

所以,你可以找到一组满足要求,并转换回(x, y)z, w)的组合。

具有最大度量的第二个方程可以写为如下:

enter image description here

这意味着(z, w)可以如下可视化。

enter image description here

同样,你可以产生这样的(z, w)对和转换回(x, y)

这是第一个等式的R代码。你可以自己尝试第二个。

library(ggplot2) 

# A is (a,b; c,d) matrix 
A <- matrix(c(1, 2, -1, 0), 
      nrow=2, ncol=2, byrow=TRUE) 
gamma <- 1 
c1 <- 0.2 
c2 <- 0.1 

############################### 
z <- seq(-gamma, gamma, length=100) 
w <- abs(gamma - abs(z)) 

z <- c(z, z) 
w <- c(w, -w) 

qplot(z, w) + coord_fixed() 

# computing back (x,y) from (z,w) 
z_mat <- rbind(z, w) 
x_mat <- solve(A, z_mat) 
x <- x_mat[1,] + c1 
y <- x_mat[2,] + c2 

qplot(x, y) + coord_fixed() 
################################