1

0.5Q+30 = −0.2Q+100

0.5q+0.2q=100-30

70=0.7q

q=70/0.7

q=100

0.5*100+30

=80

Is there a package that solves equations with variables on both sides?

Dave2e
  • 22,192
  • 18
  • 42
  • 50
KmnsE2
  • 424
  • 2
  • 9

1 Answers1

2

One option is to subtract the right hand side from the left and then use uniroot to solve it.

#0.5Q+30 = −0.2Q+100
leftside <- function(Q){
   x<- 0.5*Q+30
   return(x)
}

rightside <- function(Q){
   x<- -0.2*Q+100
   return(x)
}

solution<-uniroot(function(Q) {leftside(Q)- rightside(Q) },  lower = 0, upper = 999)
print(solution$root)

leftside(solution$root)
Dave2e
  • 22,192
  • 18
  • 42
  • 50