text:
# 祖玛(Zuma)

### Description

Let’s play the game Zuma!

There are a sequence of beads on a track at the right beginning. All the beads are colored but no three adjacent ones are allowed to be with a same color. You can then insert beads one by one into the sequence. Once three (or more) beads with a same color become adjacent due to an insertion, they will vanish immediately.

Note that it is possible for such a case to happen for more than once for a single insertion. You can’t insert the next bead until all the eliminations have been done.

Given both the initial sequence and the insertion series, you are now asked by the fans to provide a playback tool for replaying their games. In other words, the sequence of beads after all possible eliminations as a result of each insertion should be calculated.

### Input

The first line gives the initial bead sequence. Namely, it is a string of capital letters from ‘A’ to ‘Z’, where different letters correspond to beads with different colors.

The second line just consists of a single interger n, i.e., the number of insertions.

The following n lines tell all the insertions in turn. Each contains an integer k and a capital letter Σ, giving the rank and the color of the next bead to be inserted respectively. Specifically, k ranges from 0 to m when there are currently m beads on the track.

### Output

n lines of capital letters, i.e., the evolutionary history of the bead sequence.

Specially, “-” stands for an empty sequence.

### Example

Input

ACCBA
5
1 B
0 A
2 B
4 C
0 A

Output

ABCCBA
AABCCBA
AABBCCBA
-
A

### Restrictions

0 <= n <= 10^4

0 <= length of the initial sequence <= 10^4

Time: 2 sec

Memory: 256 MB

List

### 限制

0 ≤ n ≤ 10^4

0 ≤ 初始珠子数量 ≤ 10^4

### 提示

 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 #include #include using namespace std; string & trim(string & s){     if(s.empty())return s;     s.erase(0,s.find_first_not_of(" "));     s.erase(s.find_last_not_of(" ")+1);     return s; } bool process_once(string & str){     char c=str[0];     int cnt=1;     for(int i=1;i=3){                 str.erase(i-cnt,cnt);                 return true;             }else{                 c=str[i];                 cnt=1;             }         }     }     if(cnt>=3)str.erase(str.length()-cnt,cnt);     return false; } void process(string & str,int pos,char c){     str.insert(pos,1,c);     while(process_once(str));     return; } int main(){     ios::sync_with_stdio(false);     string str;     int n;     cin>>str>>n;     for(int i=0;i>pos>>c;         process(str,pos,c);         trim(str);         if(str.length()==0)cout<<"-"<


text:
# Magnetic Field from a Graph?

## Homework Statement

I have a graph of an emf of a generator vs time, and i know the cross-sectional area per turn is 0.03m^2 and there are 160 turns. From the wave graph I figured out the frequency of the generator is 2.4Hz and the angular speed is 14.96rad/s. I need to figure out the magnetic field.

e=-NAcos0B/t

## The Attempt at a Solution

I found the frequency and angular speed from the graph but I have no idea how to find the magnetic field from a graph. Please help. Thank you.

Related Introductory Physics Homework Help News on Phys.org
It's important to realise that the emf is directly proportional to the change of magnetic flux:

$$\Phi = BS\cos{\omega}t$$

$$emf = -N \frac{d\Phi}{dt}$$,

that is:

$$emf = -NBS \frac{d}{dt}\cos{\omega}t = -NBS\omega\sin{\omega}t$$

Then rearrange it to get the formula for B.

Last edited:
Ok so I rearranged the formula to get B=emf/-NAwsinwt
= 28/(-160)(.03)(14.96)(sin(14.96*.315))
=28/71.808
=0.38993
Is that correct? Thanks!

format: plain


text:
# Problem with fortran and lapack

• Fortran

## Main Question or Discussion Point

Hi there. I'm trying to solve a linear system which I have constructed with the aim of learning how to do this in fortran. The idea is to solve:

##A\vec{x}=\vec{b}##

The thing is that when I call the subroutine degsv from lapack to solve the linear system, and then write the solution, it only prints the vector b, and I can't find what I am doing wrong. It should solve the system by calling dgesv, and then print x in b.

This is the code:

Fortran:
      program matrix

!.... This program constructs a matrix A, a vector b, and then solves
!.... the system Ax=b using the lapack package.

implicit none

integer mxpts
parameter (mxpts=5000)
integer i,j,rows,cols,k,aux,pivot(3),ok

real*8 A(mxpts,mxpts),b(mxpts),c,x(mxpts)

open (unit=10,file='matrix.dat',status='unknown')
open (unit=20,file='rhs.dat',status='unknown')

!..... Inputs

rows=3
cols=rows !square matrix

!..... Coefficients
!..... Initialization

do i=1,rows
b=0.0d0
do j=1,cols
A(i,j)=0.0d0
enddo
enddo

!..... Matrix preparation

do i=1,rows
do j=1,cols
k=i+j
aux=mod(k,3)
c=1.0d0
if(aux.eq.1) c=-1.0d0
!          print*,k,aux,c
A(i,j)=(i+j)*j*c
print 200,i,j,A(i,j)
enddo
enddo

!..... Vector preparation for the right hand side of A*x=b.

do i=1,rows
b(i)=i
print*,i,b(i)
enddo

200   format(4x,"A(",i1,",",i1,")=",1pg15.8)  !,f10.8)

!..... 4x: 4 espacios en blanco, i1 imprime entero y le asigna 1 espacio
!..... 1pg10.5 imprime real, le asigna 10 espacios donde 5 son para
!..... decimales.

!..... Print Matrix

do i=1,rows
do j=1,cols
write (10,*)A(i,j)
enddo
enddo

!      do i=1,rows
!        print*,( A(i,j), j=1,cols)
!      enddo

!..... Find the solution x=A-1*b

call dgesv (rows, 1, A, 3, pivot, b, 3, ok)
c
c parameters in the order as they appear in the function call
c    order of matrix A, number of right hand sides (b), matrix A,
c    leading dimension of A, array that records pivoting,
c    result vector b on entry, x on exit, leading dimension of b
c    return value
c
c print the vector x

do i=1,rows
print*,b(i)
write (20,*) b(i)
end do

stop
end

Last edited by a moderator:

Related Programming and Computer Science News on Phys.org
Mark44
Mentor
Telemachus
Hello Mark. Thank you very much for your feedback. I'm not really sure about that, because its the first time I'm attempting to use lapack. I have set those parameters while following this example: http://physics.oregonstate.edu/~landaur/nacphy/lapack/codes/linear-f.html , which works well, but uses sgesv (I have assumed that for dgesv should be the same, and I had took a look at the lapack documentation, but as I said, I'm not an expert).

I have tried as you said to put that parameter equal to zero, but I get this error when I run the program:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0 0x7F9354A59E08
#1 0x7F9354A58F90
#2 0x7F93546AA4AF
#3 0x7F9354F11F18
#4 0x400F2D in MAIN__ at matrix.f:?
Segmentation fault (core dumped)

That parameter is associated with an output from lapack.

Here are my sugggestions:

1) The Lapack routine dgesv solves the linear system AX=B, where A and B are matrices. So, if you want to solve for the case where the right-hand side is a vector you should declare B as a two-dimensional array of size (n,1) where n is the number of rows.
2) Before you call dgesv you need to compute the LU factorization of A by using the routine DGETRF. This routine produces an array which contains the pivot indices. In your case it is the variable called pivot. But, I suppose that for the moment this array only contains zeros because you don't call DGETRF.
3) As Mark44 said please print out and post the value of the variable "ok".

Mark44
Mentor
I have tried as you said to put that parameter equal to zero
No, the 6th parameter is an output variable. You don't set it -- the function sets it, with 0 indicating a successful completion. If the value is negative or positive, the value gives useful information, as explained in the documentation page I linked to.

3) As Mark44 said please print out and post the value of the variable "ok".
From the page in the link:
SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )
Of these six parameters, A and B are input/output, which means they must be set when the subroutine is called, but can be changed by the subroutine.
IPIV and INFO are output parameters, which means they can be anything when the subroutine is called, but get set by the subroutine.

Telemachus
DrClaude
Mentor
1) The Lapack routine dgesv solves the linear system AX=B, where A and B are matrices. So, if you want to solve for the case where the right-hand side is a vector you should declare B as a two-dimensional array of size (n,1) where n is the number of rows.
This is not necessary. Since Fortran is "pass by reference," the address of the first element is passed to the routine, and the shape of b doesn't matter.

Here are my sugggestions:
2) Before you call dgesv you need to compute the LU factorization of A by using the routine DGETRF. This routine produces an array which contains the pivot indices. In your case it is the variable called pivot. But, I suppose that for the moment this array only contains zeros because you don't call DGETRF.
That's incorrect. dgsev calls dgetrf itself on line 167.

Telemachus
DrClaude
Mentor
integer mxpts
parameter (mxpts=5000)
integer i,j,rows,cols,k,aux,pivot(3),ok
There is a first problem here: pivot has to be the same size as the actual matrix A, so you should declare it as size mxpts.

call dgesv (rows, 1, A, 3, pivot, b, 3, ok)
The dimensions here are all wrong.
SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )

The first 3 parameters are fine, but LDA = 3 is incorrect. LDA is the distance in memory between the the first element in the column and the first element in the column next to it. In other words, it is the first dimension of A, so mxpts.

As I said above, IPIV is of size N, which is not how you declared pivot.

As for LDA, LDB should be the first dimension of B, so also mxpts.

This is all explained in the comments at the top of the LAPACK routine. You can also check this information on netlib.

Telemachus
I've found the problem, the thing seems to be that I have specified the matrix to be from a size which doesn't correspond to the size I was trying to solve. I have changed the value of the parameter mxpts, and then used mxpts as the input to call dgesv.

Thank you all.

There is a first problem here: pivot has to be the same size as the actual matrix A, so you should declare it as size mxpts.

The dimensions here are all wrong.
SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )

The first 3 parameters are fine, but LDA = 3 is incorrect. LDA is the distance in memory between the the first element in the column and the first element in the column next to it. In other words, it is the first dimension of A, so mxpts.

As I said above, IPIV is of size N, which is not how you declared pivot.

As for LDA, LDB should be the first dimension of B, so also mxpts.

This is all explained in the comments at the top of the LAPACK routine. You can also check this information on netlib.
You are totally right. Thank you very much.

I don't know if I should start another topic for this. The thing is that fortran after running dgesv to solve ##A\vec{x}=b## gives me this message:

user@user-desktop:~/Desktop/radtransf$./matrix.x rmax= 10.000 npoints= 5000 Dr= 2.00000E-03 Rows,hrows= 10000 5000 Info= 0 Note: The following floating-point exceptions are signalling: IEEE_DENORMAL What could be the problem? DrClaude Mentor That seems to be some kind of underflow. What compiler are you using? Since you get back info = 0, I wouldn't worry too much. You can always check the result: Does Ax give you back b? Last edited: Telemachus I'm using gfortran. I'll try to do Ax to get b. Now one of the ##x_i## is wrong, and I know that because it is set to zero when constructing the matrix, its a boundary condition, but when lapack does its work it seems to change its value to some small but non zero number. DrClaude Mentor I'm using fortran. From what I could find on the web, there was a problem with gfortran throwing floating point exceptions. I really wouldn't worry too much. I'll try to do Ax to get b. Now one of the ##x_i## is wrong, and I know that because it is set to zero when constructing the matrix, its a boundary condition, but when lapack does its work it seems to change its value to some small but non zero number. You have to have some tolerance for numerical errors. What kind of numbers are you getting instead of 0? Telemachus 4.6338717745555646E-015 With typical values beeing like: E-04 to E-06 the algorithm doesn't seems to be working. I'm trying to solve an integrodifferential equation, and I get nusty things. BTW: Have you ever worked with the ##S_N## approximation to the Boltzmann equation? After checking, its clearly not working. This is the code, i'll attach it with the input if you want to check. Fortran:  program radtransf !Nov 29 2016 !...... This program calculates the solution for the radiative transfer !...... equation in the Sn approximation, with n=2. The program starts !...... by building a Matrix for the discretized system of coupled !...... differential equations, obtained by the Diamond difference scheme. !...... Version 0.0.1 implicit none real*8 Dr,rmax integer npoints common/bkinput/ Dr,rmax,npoints !....... Input file open (unit=10,file='radtrans.inp',status='old') !....... call input call readinput !....... Matrix generation and resolution call matrix !...... Close files close (unit=10) close (unit=17) close (unit=18) close (unit=19) close (unit=20) stop end !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine readinput implicit none !...... Input parameters real*8 Dr,rmax integer npoints common/bkinput/ Dr,rmax,npoints real*8 rzero, one, two, five data rzero,one,two,five/0.0d0,1.0d0,2.0d0,5.0d0/ namelist /griddata/Dr,npoints,rmax Dr=rzero npoints=0 rmax=rzero !...... read griddata read(10,griddata) if (rmax.eq.rzero) rmax=Dr*npoints if (Dr.eq.0) Dr=rmax/npoints write(*,111) rmax,npoints,Dr 111 format(/5x,'rmax=',f9.3,5x,'npoints=',i8,5x,'Dr=',1pg12.5) return end !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine matrix !.... This program constructs a matrix A, a vector b, and then solves !.... the system Ax=b using the lapack package. implicit none real*8 Dr,rmax integer npoints common/bkinput/ Dr,rmax,npoints integer mxpts parameter (mxpts=10000) integer i,j,rows,hrows,cols,k,aux,pivot(mxpts),info real*8 A(mxpts,mxpts),b(mxpts),v(mxpts),c,x,mu1,mu2 real*8 one, two, four, hundred data one, two, four, hundred/ 1.0d0, 2.0d0, 4.0d0, 100.0d0/ !..... Output files ! open (unit=16,file='rhs.dat',status='unknown') open (unit=17,file='matrix.dat',status='unknown') open (unit=18,file='Psi1.dat',status='unknown') open (unit=19,file='Psi2.dat',status='unknown') open (unit=20,file='check.dat',status='unknown') !..... Inputs rows=2*npoints hrows=npoints cols=rows !square matrix print*,'Rows,hrows=',rows,hrows !..... Coefficients !..... Initialization mu1=dsqrt(1.0d0/3.0d0) mu2=-1.0d0*dsqrt(1.0d0/3.0d0) do i=1,rows b=0.0d0 do j=1,cols A(i,j)=0.0d0 enddo enddo !..... Build matrix A do i=1,hrows do j=1,cols if(i.eq.1 .and. i.ne.j) then A(i,j)=0.0d0 else if(i.eq.1 .and. i.eq.j) then A(i,j)=1.0d0 else if(i.ne.1 .and. i.eq.j) then A(i,j)=two*mu1 else if(i.ne. 1 .and. i-1 .eq. j) then A(i,j)=-two*mu1 else if(i.ne.1 .and. i+j.eq.rows+1) then A(i,j)=-hundred*Dr else if(i.ne.1) then A(i,j)=0.0d0 endif enddo enddo do i=hrows+1,rows do j=1,cols if(i.eq.hrows+1 .and. i.ne.j) then A(i,j)=0.0d0 else if(i.eq.hrows+1 .and. i.eq.j) then A(i,j)=1.0d0 else if(i.ne.hrows+1 .and. i.eq.j) then A(i,j)=-two*mu2 else if(i.ne.hrows+1 .and. i-1.eq.j) then A(i,j)=two*mu2 else if(i.ne.hrows+1 .and. i+j.eq.rows+1) then A(i,j)=-hundred*Dr else if(i.ne.hrows+1) then A(i,j)=0.0d0 endif enddo enddo ! do i=1,rows ! do j=1,cols ! print 200,i,j,A(i,j) ! enddo ! enddo !..... Vector preparation for the right hand side of Ax=b. do i=1,rows b(i)=0.01d0*Dr enddo b(1)=0.0d0 b(hrows+1)=0.0d0 ! do i=1,rows ! print*,b(i) ! end do !200 format(4x,"A(",i5,",",i5,")=",1pg15.8) !,f10.8) !..... Print Matrix do i=1,rows do j=1,cols write (17,200)i,j,A(i,j) enddo enddo 200 format(4x,"A(",i5,",",i5,")=",1pg15.8) !,f10.8) ! do i=1,rows ! print*,( A(i,j), j=1,cols) ! enddo !..... Find the solution x=A-1*b call dgesv (rows, 1, A, mxpts, pivot, b, mxpts, info) print*,"Info=",info do j=1,hrows+1 x=(j-1)*Dr write(18,*)x,b(j) end do do i=hrows,rows x=(i-hrows)*Dr write(19,*)x,b(hrows+1+rows-i) end do !..... Verification for Ax=b do i=1,rows do j=1,cols v(i)=A(i,j)*b(j) write(20,*)v(i) enddo enddo ! do i=1,rows ! b(i)=0.01d0*Dr ! write(20,*)v(i),b(i) ! enddo return end !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Ok, now I see that I was thinking too much symbolically. I think now the matrix product is ok: Fortran: !..... Verification for Ax=b !..... Initialization do i=1,rows v(i)=0.0d0 enddo rsum=0.0d0 sumaux=0.0d0 !..... Verification for Ax=b do i=1,rows do j=1,cols sumaux=A(i,j)*b(j) rsum=rsum+sumaux v(i)=rsum enddo write(20,*)v(i) enddo Anyway, only the first element of the array gives the correct value. #### Attachments • 5.6 KB Views: 350 • 184 bytes Views: 341 Last edited: Please, notice that the matrix A is changed by dgesv. So, to do the test you need to make a copy of A before calling that subroutine. Telemachus Mark44 Mentor Please, notice that the matrix A is changed by dgesv. So, to do the test you need to make a copy of A before calling that subroutine. @Telemachus, here's what I said in post #5: Of these six parameters, A and B are input/output, which means they must be set when the subroutine is called, but can be changed by the subroutine. When you're using the lapack routines (or, in fact, the routines in any library), it's very important to read and understand the documenation for the routines. Telemachus Thanks. And sorry for not giving the proper attention to those important recommendations, I am too anxious trying to make this work, so sorry for that, and thank you all for your patience, I'll try to not commit those mistakes again, and to be more lucid in the future. I have rebuilt the matrix after calling dgesv. Still not giving the correct right hand side after matrix multiplication. Could this be a consequence of the matrix A being ill conditioned? I haven't proven it is actually ill conditioned, but I think it could be the case. Last edited: Hi again. I'm having additional problems with this code. When I try to build a bigger matrix, so I can get a finer grid, I have an upper bound. When I try to set the parameter mxpts>20000, I get this error when I try to compile it: :~/Desktop/radtransf$ gfortran radtrans.f -llapack -o radtrans.x
/tmp/ccNJ2Cfs.o: In function matrix_':
radtrans.f:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0x1a3): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0x494): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0x6d0): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0x77f): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0x922): relocation truncated to fit: R_X86_64_32 against .bss'
radtrans.f:(.text+0x9eb): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0xacc): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0xda8): relocation truncated to fit: R_X86_64_PC32 against symbol bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o
radtrans.f:(.text+0xfe4): relocation truncated to fit: R_X86_64_PC32 against symbol `bkinput_' defined in COMMON section in /tmp/ccNJ2Cfs.o

If the parameter (which is used to store the arrays for matrix and vectors) is smaller than 20000, then the program compiles without any problem.

Maybe, you don't have enough RAM memory. How much memory do you have on your computer?
With the dimension 20 000, you will have 4*10^8 matrix elements, where each of them is a double-precision number. And with several arrays/matrices it gets even worse.

Telemachus
The compilller knows that? I'm short of ram, 3.8gb.

Now I'm going to explain in more detail what the program does, so perhaps if I'm committing some mistake in the derivation of the difference scheme, you can advise me.

I am trying to solve the stationary Boltzmann transport equation in slab geometry with isotropic scattering.

##\displaystyle \mu \frac{d \psi(x,\mu)}{dx}+\sigma_T \psi(x,\mu)= \sigma_s \int_{-1}^{1}\psi(x,\mu')d\mu'+Q(x,\mu)##

I'm being quiet general, and then I'll go through the steps into the particular case I am trying to solve. So, this equation model the stationary angular flow of particles ##\psi(x,\mu)## at point ##x## in the direction of ##\mu##. ##\sigma_T## is the total cross section: ##\sigma_T=\sigma_s+\sigma_a##, ##\sigma_s## is the scattering cross section, and ##\sigma_a## is the absorption cross section. This is a very general equation that models many types of transport phenomena. I'm interested in particular in radiative transfer problems, but its used in plasma physics, hydrodynamics, nuclear reactor design, etc, etc. As you can see its an integrodifferential equation, and is not that trivial to solve. I am trying to reproduce a case in this paper (the first in the section of numerical results): http://www.sciencedirect.com/science/article/pii/0021999187901707

This equation in this regime asymptotically behaves as a diffusion equation, which I have solved analytically (its very simple), and the numerical result is show in the paper, with which it agrees, so I in advance know what the solution should be.

Now, this equation has to be discretized in both variables it depends on (even in one dimension one has scattering from all directions). To solve the integral on the right hand side it is used a Gauss-Legendre quadrature (known as the ##S_N## approximation, I have started with N=2, the paper does it for N=8).

In general one has:

##\displaystyle \mu_m \frac{d \psi_m(x)}{dx}+\sigma_T \psi_m(x)=\sigma_s \sum_{m'} w_{m'} \psi_m' +Q(x)## (1)

This is a set of coupled differential equations (the scattering term in the rhs couples all directions in the flux).

To do the spatial discretization, one defines the cell average flux:

##\displaystyle \psi_{m,j}=\frac{1}{\Delta x_j} \int_{x_{j-1/2}}^{x_{j+1/2}} \psi_m(x)dx##

Then, integrating the eq. (1) in the j cell and dividing by ##\Delta x_j=x_{j+1/2}-x_{j-1/2}##

One arrives to:

##\mu_m \left ( \psi_{m,j+1/2}-\psi_{m,j-1/2} \right )+\Delta x_j \sigma_{T,j} \psi_{m,j}=\sigma_{s,j} \Delta x_j \sum_{m'} \psi_{m',j}w_{m'}+Q_j \Delta x_j##

At this point one defines the discretization scheme by connecting the cell edges (all half integers in the subindexes of x's), with the cell centers (all integer subindexes in x's).

I am using the Diamond difference scheme:

##\psi_{m,j}=\frac{1}{2} \left ( \psi_{m,j+1/2}+\psi_{m,j-1/2} \right )##

From this equation I eliminate ##\psi_{m,j+1/2}## for the equations in which ##\mu>0##

And ##\psi_{m,j-1/2}## for the equations in which ##\mu<0##

The case I want to solve is with ##\sigma_T=\sigma_s=100## independent of x, and ##Q=0.01##, with boundary conditions:

##\psi_m(0)=0## for ##\mu>0##
##\psi_m(10)=0## for ##\mu<0##

When I construct the matrix I drop the half integer indexes, that could be a mistake, but I'm not sure, I just thought that I could redefine the half integers, and everything would be the same, but now I'm not that sure.

For ##S_2##, with only two spacing I get this system of equations:

##2\mu_1 \psi_{1,i}-2\mu_1\psi_{1,i-1}-100\Delta x_i \psi_{2,i}=0.01\Delta x_i##

##-2\mu_2 \psi_{2,i}+2\mu_2\psi_{2,i+1}-100\Delta x_i \psi_{1,i}=0.01\Delta x_i##

For this case I build this matrix, the first and third row indicate the boundary condition:

##\begin{bmatrix} 1 & 0 & 0 & 0 \\ -2\mu_1 & 2\mu_1 & -100\Delta x_1 & 0 \\ 0 & 0 & 1 & 0 \\ -100 \Delta x_1 & 0 & 2mu_2 & -2\mu_2 \end{bmatrix} \left[ \begin{array}{c} \psi_{1,1} \\ \psi_{1,2} \\ \psi_{2,2} \\ \psi_{2,1} \end{array} \right] = 0.01\times \left[ \begin{array}{c} 0 \\ \Delta x_1 \\ 0 \\ \Delta x_1 \end{array} \right]##

Then I did the same for 4 spatial intervals, and then I've generalized for the routine I wrote in the program, which works well for this two test cases.

Last edited:
DrClaude
Mentor
The memory problem seems to be related to a common block. These have to be allocated as a single chunck of memory, so there might be a size limit. In any case, I don't think that solving for a 20000x20000 matrix can be done in any reasonable amount of time.

I'm not sure I understand the structure of the matrix you obtain. Is it tridiagonal?

Telemachus
No, it isn't, because I have terms that couples all equations. For the 4 spacing case this is the matrix I have obtained and from which I did the general case for any spacing:

##\begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
-2\mu_1 & 2\mu_1 & 0 & 0 & 0 & 0 & -100\Delta x_2 & 0 \\
0 & -2\mu_1 & 2\mu_1 & 0 & 0 & -100\Delta x_3 & 0 & 0 \\
0 & 0 & -2\mu_1 & 2\mu_1 & -100\Delta x_4 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & -100 \Delta x_3 & 0 & 2\mu_2 & -2\mu_2 & 0 & 0 \\
0 & -100 \Delta x_2 & 0 & 0 & 0 & 2\mu_2 & -2 \mu_2 & 0 \\
-100 \Delta x_1 & 0 & 0 & 0 & 0 & 0 & 2\mu_2 & -2\mu_2
\end{bmatrix} \left[ \begin{array}{c} \psi_{1,1} \\ \psi_{1,2} \\ \psi_{1,3} \\ \psi_{1,4} \\ \psi_{2,4} \\ \psi_{2,3} \\ \psi_{2,2} \\ \psi_{2,1} \end{array} \right] = 0.01\times \left[ \begin{array}{c} 0 \\ \Delta x_2 \\ \Delta x_3 \\ \Delta x_4 \\ 0 \\ \Delta x_3 \\ \Delta x_2 \\ \Delta x_1 \end{array} \right]##

In the case I'm working with all ##\Delta x_i## are equal, I'm using a uniform grid.

I have seen methods in the bibliography that obtain a Lower triangular matrix by using an iteration scheme in a way that the upper lower terms goes to the right hand side of the equation (those terms comes from the integral, they solve the ingegral recursively by updating the ##\psi##). Perhaps I'll try with that, but I have also read that the convergence for the high scattering case (the one I'm dealing with belongs to that category) is slow (this can be explained on physical grounds), so I would have complications in that sense too. The paper anyways gets the answer, and is from 1987, so I must be doing something wrong.

The problem could be at this point:

This is the equation I have to solve:
(1) ##\mu_m \left ( \psi_{m,j+1/2}-\psi_{m,j-1/2} \right )+\Delta x_j 100 \psi_{m,j}=100 \Delta x_j \sum_{m'} \psi_{m',j}w_{m'}+ 0.01 \Delta x_j##

I am using the Diamond difference scheme:

##\psi_{m,j}=\frac{1}{2} \left ( \psi_{m,j+1/2}+\psi_{m,j-1/2} \right )##

So what I do is to eliminate ##\psi_{m,j+1/2}## when ##\mu_m>0## (in this case the boundary condition is ##\psi(0)=0##, so I need to go in the forward direction, and I need the previous step to update):

##\psi_{m,j+1/2}=2\psi_{m,j}-\psi_{m,j-1/2}##

And I eliminate ##\psi_{m,j-1/2}## when ##\mu_m<0## (in this case I go in the backward direction, and the boundary condition is ##\psi(10)=0##):

##\psi_{m,j-1/2}=2\psi_{m,j}-\psi_{m,j+1/2}##

So, depending on the sign of ##\mu## I use this conditions in equation (1), so, for example, for ##S_2## with ##\mu>0## I get:

##2\mu_1 \psi_{1,j}-2\mu_1\psi_{1,j-1/2}-100\Delta x_i\psi_{2,i}=0.01 \Delta x_i##

And for ##\mu<0## (this always comes in pairs with opposite sign) I get:

##-2\mu_2 \psi_{2,j}+2\mu_2\psi_{1,j+1/2}-100\Delta x_i \psi_{1,i}=0.01 \Delta x_i##

You must have in mind that in this case ##w_{m'}=1##, all weights are equal, so I have canceled the terms on the right hand side with those on the lhs, and ##\mu_1=-\mu_2=\sqrt{\frac{1}{3}}##

Now, when I build the matrix, I dropped the subindexes ##\psi_{m,j-1/2}## and ##\psi_{m,j+1/2}## and just called them ##\psi_{m,i-1}## and ##\psi_{m,i+1}##. Now I think that could be a mistake, but I'm not sure on how to fix it. I think that the matrix should take the information from the half integer x's which corresponds to the boundaries of the cell's, but should only operate on the center of the cells somehow (but I'm not totally sure of this).

This is a cell, the center and the boundaries:
__________________________
|[COLOR=#black]....................[/COLOR]|[COLOR=#black]...................[/COLOR]|
##x_{1/2}##[COLOR=#black]............[/COLOR]##x_{1}##[COLOR=#black]..............[/COLOR] ##x_{3/2}##

Last edited:


text:
# how to tell a fraction in denominator or numerator should be substituted with its integer equivalent

Suppose we have equations as follows (A, C and B are all integers and $\gcd$=greatest common divisor). $$R_1 = \frac{A\times C}{B} \hspace{2cm} R_2 = \frac{A\times\frac{C}{\gcd(B,C)}}{\frac{B}{\gcd(B,C)}}$$ Now If I'm not making any mistake $R_2$ can mean two fractions, one named $R_3$ of which the numerator and denominator are in order the integer results of $A\times\frac{C}{\gcd (B,C)}$ and $\frac{B}{\gcd (B,C)}$ expressions and one named $R_4$ that is $\frac{A\times C\times\gcd (B,C)}{B\times\gcd (B,C)}$ , although $R_3$ and $R_4$ are equivalent but I want $R_2$ notation to illustrate $R_3$ so is there any kind of operator or something that I can use to tell fractions in numerator and denominator of $R_2$ should be substituted with their integer equivalents, specially when I'm writing in Microsoft word?

• Consider finding a better way to format your question to improve readability. The following can help you with some of that: meta.math.stackexchange.com/questions/5020/… – Vincent Aug 4 '14 at 9:33
• ok trying to ... – Pooria Aug 4 '14 at 9:40
• $\lfloor x \rfloor$ is the largest integer smaller than $x$. – Karolis Juodelė Aug 4 '14 at 10:23
• yeah I also thought of that but that doesn't seem to suit in this case because any number is always divisible by it's gcd with another number – Pooria Aug 4 '14 at 10:58
• Maybe introduce new variables denoting integers: $R_2 = \frac{A\times C^{'}}{B^{'}}\qquad$ where $C^{'} = \frac{C}{\gcd(B,C)}$ and $B^{'} = \frac{B}{\gcd(B,C)}$ are both integers. – Mick A Aug 4 '14 at 13:24

ok the part I was hoping I didn't make a mistake actually I did, $R_2$ means $R_4$ and not $R_3$, $R_3$ is a fraction equivalent to $R_2$, the solution is to use variables of integer type so expressing R2 in the correct way as I intend is as it follows:
$$integer1=\frac{C}{\gcd (B,C)} \hspace{2cm} integer2=\frac{B}{\gcd (B,C)}$$ $$R_2=\frac{A\times integer1}{integer2}$$


text:
Interacting with an Experiment from the Virtual Coach¶

In the previous section we successfully launched a simulation of the Template Husky experiment. In this tutorial, we will interact with the simulation through the Virtual Coach.

Getting and Setting Simulation States¶

When an experiment is launched, it is initially in the paused state. This means the experiment has to be explicitly started. In general, we can query the simulation state by calling:

sim.get_state()

The state of the simulation is returned as a string. In this case calling get_state() will return paused. The possible states we can set a simulation to are paused, started and stopped. We can alternatively start and pause the simulation by calling:

sim.pause()
sim.start()

Note that the timeout for a simulation is 15 minutes.

Transfer Functions¶

From the Virtual Coach, we can view transfer functions, modify them, delete them, or add new ones. The transfer functions unique identifiers are their function names. To know the names of the transfer functions defined in an experiments, we can call:

sim.print_transfer_functions()

which would just print out the names of the transfer functions. In the case of the Template Husky experiment, this call will print out: turn_around, csv_spike_monitor, all_neurons_spike_monitor, grab_image, and csv_joint_state_monitor. To actually see the code of a transfer function, we can use the get_transfer_function call, which takes the transfer function name as a parameter and returns the code in a string. We will get the code of the turn-around transfer function and store it in a variable:

turn_around_tf = sim.get_transfer_function('turn_around')

If you’re using a jupyter notebook, you can use the %load command to load the transfer function code in a cell. This will allow you to see the code syntax highlighted and properly indented and will make it easier to modify the functions:

%load turn_around_tf

This should load this function in a new cell in the jupyter notebook:

import hbp_nrp_cle.tf_framework as nrp
from hbp_nrp_cle.robotsim.RobotInterface import Topic
import geometry_msgs.msg
@nrp.MapSpikeSink("output_neuron", nrp.brain.neurons[1], nrp.leaky_integrator_alpha)
@nrp.Neuron2Robot(Topic('/husky/husky/cmd_vel', geometry_msgs.msg.Twist))
# Example TF: get output neuron voltage and output constant on robot actuator. You could do something with the voltage here and command the robot accordingly.
def turn_around(t, output_neuron):
voltage=output_neuron.voltage
return geometry_msgs.msg.Twist(linear=geometry_msgs.msg.Vector3(0,0,0),
angular=geometry_msgs.msg.Vector3(0,0,5))

You can modify the code however you want and then save it as a string. Here we’ll just increase the angular velocity by modifying the last line in the above code and replacing the number 5 with 10. We will save the modified code as a string in the variable turn_around_tf:

turn_around_tf = """
import hbp_nrp_cle.tf_framework as nrp
from hbp_nrp_cle.robotsim.RobotInterface import Topic
import geometry_msgs.msg
@nrp.MapSpikeSink("output_neuron", nrp.brain.neurons[1], nrp.leaky_integrator_alpha)
@nrp.Neuron2Robot(Topic('/husky/husky/cmd_vel', geometry_msgs.msg.Twist))
# Example TF: get output neuron voltage and output constant on robot actuator. You could do something with the voltage here and command the robot accordingly.
def turn_around(t, output_neuron):
voltage=output_neuron.voltage
return geometry_msgs.msg.Twist(linear=geometry_msgs.msg.Vector3(0,0,0),
angular=geometry_msgs.msg.Vector3(0,0,10))
"""

This modified transfer function will only make the robot spin faster in this experiment. If you open your frontend web cockpit and join the running experiment, you will see the robot spinning faster once we actually apply the transfer function. To apply the transfer function we use the call edit_transfer_function which takes as parameters the name of the transfer function to be modified and the modified code.

sim.edit_transfer_function('turn_around', turn_around_tf)

The Virtual Coach will maintain the simulation state after setting the transfer function. This means that if the simulation was running, the Virtual Coach will modify the transfer function and then automatically start the simulation again.

As a user you can also delete transfer functions from the Virtual Coach. You just need to provide the name of the transfer function and use it in the following call:

sim.delete_transfer_function('turn_around')

This will delete the turn_around transfer function we just modified. If you have a frontend web cockpit joined on your simulation, you will notice that the robot stopped spinning since the transfer function responsible for that behavior has been deleted. Note that deletion and addition of transfer functions are not reflected in the frontend. If you want more proof that the transfer function has been deleted, you can revisit the print_transfer_functions call and make sure that it doesn’t print out turn_around.

We can also add new transfer functions. For this we only need to provide the transfer function code as a string parameter to the add_transfer_function function. We don’t have to provide a name since the name will just be the function’s name. Remember that transfer functions definition names have to be unique, so duplicate function names will result in errors. Here we’ll create three transfer functions that store Spike, Joint and Robot positions into csv files.

csv_spike_monitor = """@nrp.MapCSVRecorder("recorder", filename="all_spikes.csv", headers=["id", "time"])
@nrp.MapSpikeSink("record_neurons", nrp.brain.record, nrp.spike_recorder)
@nrp.Neuron2Robot(Topic('/monitor/spike_recorder', cle_ros_msgs.msg.SpikeEvent))
def csv_spike_monitor(t, recorder, record_neurons):
for i in range(0, len(record_neurons.times)):
recorder.record_entry(
record_neurons.times[i][0],
record_neurons.times[i][1]
)"""

csv_joint_state_monitor = """@nrp.MapRobotSubscriber("joint_state", Topic('/husky/joint_states', sensor_msgs.msg.JointState))
def csv_joint_state_monitor(t, joint_state, recorder):
if not isinstance(joint_state.value, type(None)):
for i in range(0, len(joint_state.value.name)):
recorder.record_entry(joint_state.value.name[i], t, joint_state.value.position[i])"""

csv_robot_position = """@nrp.MapCSVRecorder("recorder", filename="robot_position.csv", headers=["x", "y", "z"])
@nrp.MapRobotSubscriber("position", Topic('/gazebo/model_states', gazebo_msgs.msg.ModelStates))
@nrp.MapVariable("robot_index", global_key="robot_index", initial_value=None)
@nrp.Robot2Neuron()
def csv_robot_position(t, position, recorder, robot_index):
if not isinstance(position.value, type(None)):

# determine if previously set robot index has changed
if robot_index.value is not None:

# if the value is invalid, reset the index below
if robot_index.value >= len(position.value.name) or\
position.value.name[robot_index.value] != 'husky':
robot_index.value = None

# robot index is invalid, find and set it
if robot_index.value is None:

# 'husky' is the bodyModel declared in the bibi, if not found raise error
robot_index.value = position.value.name.index('husky')

# record the current robot position
recorder.record_entry(position.value.pose[robot_index.value].position.x,
position.value.pose[robot_index.value].position.y,
position.value.pose[robot_index.value].position.z)"""

Those transfer functions will log the simulation time to the log console every two seconds.

Getting Experiment Data¶

With the transfer functions that we wrote, we can access all experiment data from the Virtual Coach and plot or analyze the data. You can specify, if you want to inspect ‘csv’ data or ‘profiler’ data, first is created with Transfer Function recording, latter from the NRP cle profiler. To know what kind of data is being saved to files in an experiment, you can print out the names of the files first using this call:

vc.print_last_run_files(exp_id, 'csv')

In the case of the Template Husky experiment, this will print out all_spikes.csv and all_joints_positions.csv and robot_position.csv. We can now get the data from any one of these files. Note that these files will be populated only if a simulation has been running. Here we will get the Spike data:

spikes = vc.get_last_run_file(exp_id, 'csv', 'all_spikes.csv')
print(spikes)
[[u'id', u'time', u'Simulation_reset'],
[u'3.0', u'0.10000000000000001', u'RESET'],
[u'4.0', u'2.6000000000000001', u''],
[u'3.0', u'57.200000000000003', u'']]

In the code snippet above you can notice the additional Simulation_reset column which automatically keeps track of reset events.

We can also write our own custom functions to plot the data we got. The following is a custom function that will plot each spike from the csv file as a blue dot. Note also that the first line in the csv data is a header that need to be accounted for when plotting.

from StringIO import StringIO
import pandas as pd
import matplotlib.pyplot as plt

spikes_df.plot.scatter('time','id')
plt.show()

State Machines¶

Through the Virtual Coach, users can interact with the simulation state machines the same way they can with the transfer functions. Currently we have only one experiment that contains a state machine. Let’s stop our current simulation and start it and see how we can interact with the state machines.

sim.stop()
exp_id = vc.clone_experiment_to_storage('ScreenSwitchingHuskyExperiment')
sim = vc.launch_experiment(exp_id)

After the experiment has been started, we can retrieve the names of the defined state machines.

sim.print_state_machines()

This call should print out HuskyAwareScreenControlling. To retrieve the code of the state machine, we will have to use its name we just got.

sm = sim.get_state_machine('HuskyAwareScreenControlling')

Since state machines are also python scripts, we can load them in jupyter notebooks with the %load command like we did with the transfer functions. Additionally, we can also edit and delete them, or add new ones, exactly like we interact with transfer functions. Below are the calls for editing, deleting and adding state machines.

sim.edit_state_machine(state_machine_name, state_machine_code)
sim.delete_state_machine(state_machine_name)

The only difference between interacting with state machines and transfer functions is that the state machines’ are not the python function names. Therefore, when adding a new state machine, the user has to explicitly give it a name.

Reset Functionality¶

It is also possible to reset certain aspects of the simulation from the Virtual Coach, exactly as it is possible from the web cockpit. There are four reset types possible from the Virtual Coach: Robot Frame, Environment, Brain, and the Full Simulation. You can reset all simulation aspects with the same call:

sim.reset('robot_pose')
sim.reset('world')
sim.reset('brain')
sim.reset('full')

If you want to look at more concrete example experiments run from the Virtual Coach, you can check out the hbp_nrp_virtual_coach/examples directory.


text:
## Data Communications

a square wave of 1000Hz is introduced into an ideal band passfilter (bandwidth = 100Hz) that is tuned to 5000Hz.  Thesignal output has an amplitude of 0.1V.  The filster is thenreturned to 9000Hz. Sketch the output waveform and calculate itsnew amplitude.  Repeat the question if the filter is returnedto 8500Hz.

• To answer this, we need to know the Fourier series for this squarewave.  We know f = 1 kHz, ω = 6.28 krad/sec

A square wave of amplitude A can be written as thefollowing:

s(t) = (4A/pi)[ sinωt + 1/3 sin3ωt + 1/5 sin5ωt+ 1/9 sin9ωt + ...]  I'll stop at the 9the harmonic asthat is the highest used in the question.

So, it is given that the amplitude of the 5th harmonic is 0.1V.  This means the following:

0.1 = (4A/pi)(1/5)  =>  4A = 1.571   => A = 1.571

So, if the filter is tuned to 9 kHz, the 9th harmonic, theresult will be Bsin 9ωt, where B = (A/pi)(1/9).  Asimpler way is just to scale this from the 5th harmonic, withvoltage 0.1.  The 9th harmonic will be 5/9 * .1 = .0556 V. You'll have to sketch this yourself.

If the filter is tuned to 8.5 kHz, and has BW = 100 Hz, noenergy is available to get through, so there will be 0output.
Get homework help


text:
# Solve Each of the Following Equation and Also Verify Your Solution: X 2 + X 8 = 1 8 - Mathematics

Sum

Solve the following equation and also verify your solution:

$\frac{x}{2} + \frac{x}{8} = \frac{1}{8}$

#### Solution

$\frac{x}{2} + \frac{x}{8} = \frac{1}{8}$
$\text{ or }\frac{4x + x}{8} = \frac{1}{8}$
$\text{ or }\frac{5x}{8} = \frac{1}{8}$
$\text{ or }x = \frac{1}{8} \times \frac{8}{5} = \frac{1}{5}$
$\text{ Verification: }$
$L . H . S . = \frac{1}{2} \times \frac{1}{5} + \frac{1}{8} \times \frac{1}{5} = \frac{1}{10} + \frac{1}{40} = \frac{5}{40} = \frac{1}{8} = R . H . S .$

Is there an error in this question or solution?

#### APPEARS IN

RD Sharma Class 8 Maths
Chapter 9 Linear Equation in One Variable
Exercise 9.1 | Q 4 | Page 5


text:
i hv joined a coching(weekdays) .i m in 12th std. pls tell me a suitable fruitful time table so that i can get into iit.and also fetch good mrx in jee 2012

3 years ago

Share

### Answers : (1)

                                        Its not very difficult to crack jee since you are a regular going student. Just devote 6 hours daily to JEE portion and devote an hour or two hours towards 12th.
I am sure you will be able to make it.
Please approve my answer if you like it. Plzzzz.

3 years ago

### Post Your Answer

More Questions On IIT JEE Entrance Exam

## Ask Experts

Have any Question? Ask Experts
Post Question

Answer ‘n’ Earn
Attractive Gift
Vouchers
To Win!!!
Click Here for details
I am an OCI (Overseas Citizen of India) and I have a doubt whether I am able to obtain a seat at the IITs? I've checked the bulletin released JEE MAIN website and it says, "OCI/PIO/Foreign...

OCi/PIO are not eligible for admission to these institutes through this channel, not this year atleast. There are a lot progressions going around on this issue and the ministry may decide to...

 Ravi one month ago

I’ve signed up for MAINS under OCI nationality. It warned me about the ineligibility of NITS, IIITS, & other CFTIs, but I’m wondering whether I can get into IIT through JEE ADVANCED? Or does...

 John Doe one month ago
Three angles of a triangle ABC are in Arithmetic progression and two sides are in the ratio b : c = √3 : √2. Find angle A.

Hii use property of AP and then use the formulae of cosine from solution of triangles to get the answer in the required format. [a^2 = b^2 + c^2 - 2bc\cos\alpha\,] Best

 Sourabh Singh 3 months ago
iam in a strong will to clear IIT JEE 2015....can you please suggest me some preparation tips.....

Preparing forIIT-JEE is surely a difficult thing but it all depends on how you manage your time. The key for this planning is to first set some long-term goals and then set up short-term...

 Saurabh Kumar one month ago

Hi, The best thing is to make a study schedule and follow it strictly. Keep a balance between theory and numericals and follow good books instead of completing many books. thanks...

 Shobhit Varshney one month ago
A ray of light is incident on a surface of glass slab at an angle 45 0 . If the lateral shift produced per unit thickness is 1/3 m, the angle of refraction produced is?

Lateral Shift(x)= t sin(i-r)/cos r Given that lateral shift per unit thickness of slab= 1/3(= lateral shift/thickness=x/t) x/l=1/3= Sin(45-r)/cos r Solve the trig. eqns to get the value of r...

 Ravi one month ago
Sir If I get admission in a 5-year Dual Degree course and get good grades at the end of second semester, can I apply for change of branch to a course which is a 4-year BTech?

Yes it is possible. One of my junior at IIT Delhi changed his stream from 5 year maths & computing to CSE B.Tech. Good Luck! Thanks & Regards Jitender Singh IIT Delhi askIITians...

 Jitender Singh 5 months ago

how to change branch after 1 year

 Vineet 5 months ago
Where CSE is better? NIT Warangal or COEP and if I get Mech at NITW also CSE with COEP then what should i choose?My likelihood ie CSE or good college ie NITW for Mech?

Undoubtedly NITW ia very good college for both mech and CSE. It is far better than COEP for CSE. But whether to take CSE in COEP or MECH in NITW depends on your interested branch and also...

 Ramreddy 4 months ago

Thank you so much but I wanna know if fee structure at NITW for MECH is less for SC candidates?

 VINAY GEDAM 4 months ago
View all Questions »


text:
# The Midpoint Formula

## In One Dimension

On a number line , the number halfway between ${x}_{1}$ and ${x}_{2}$ is

$\frac{{x}_{1}+{x}_{2}}{2}$

Example 1:

Find the midpoint between $-1$ and $4$ .

Use the formula. The midpoint is

$\frac{-1+4}{2}=\frac{3}{2}=1.5$ .

Example 2:

If $0.5$ is the midpoint of $\stackrel{¯}{PR}$ and the coordinate of $P$ is $-4$ , find the coordinate of $R$ .

Use the formula.

$\frac{-4+{x}_{2}}{2}=0.5$

To begin solving, multiply both sides by $2$ .

$-4+{x}_{2}=1$

Next, add $4$ to both sides.

${x}_{2}=5$

So, the coordinate of $R$ is $5$ .

## In Two Dimensions

Suppose you are given two points in the plane ( ${x}_{1}$ , ${y}_{1}$ ) and ( ${x}_{2}$ , ${y}_{2}$ ), and asked to find the point halfway between them. The coordinates of this midpoint will be:

$\left(\frac{{x}_{1}+{x}_{2}}{2},\frac{{y}_{1}+{y}_{2}}{2}\right)$

An easy way to think about this is that the $x$ -coordinate of the midpoint is the average of the $x$ -coordinates of the two points, and likewise with the $y$ -coordinate.

Example 1:

Find the midpoint between $\left(-2,5\right)$ and $\left(7,7\right)$ .

Use the formula. The coordinates of the midpoint are:

$\left(\frac{-2+7}{2},\frac{5+7}{2}\right)$

Simplify.

$\left(2.5,6\right)$

Example 2:

If $Q\left(2,-2\right)$ is the midpoint of $\stackrel{¯}{PR}$ and $P$ has the coordinates $\left(-6,-6\right)$ , find the coordinates of $R$ .

Use the formula to write and solve two equations for the coordinates of $R$ .

$Q\left(2,-2\right)=\left(\frac{-6+{x}_{2}}{2},\frac{-6+{y}_{2}}{2}\right)$

First, find the $x$ -coordinate.

$\begin{array}{l}2=\frac{-6+{x}_{2}}{2}\\ 4=-6+{x}_{2}\\ 10={x}_{2}\end{array}$

Then, find the $y$ -coordinate.

$\begin{array}{l}-2=\frac{-6+{y}_{2}}{2}\\ -4=-6+{y}_{2}\\ \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}2={y}_{2}\end{array}$

So, the coordinates of $R$ are $\left(10,2\right)$ .

## In Three Dimensions

It's pretty easy to guess based on the formula for two dimensions!

In $3$ -dimensional space, the midpoint between ( ${x}_{1}$ , ${y}_{1}$ , ${z}_{1}$ ) and ( ${x}_{2}$ , ${y}_{2}$ , ${z}_{1}$ ) is

$\left(\frac{{x}_{1}+{x}_{2}}{2},\frac{{y}_{1}+{y}_{2}}{2},\frac{{z}_{1}+{z}_{2}}{2}\right)$


text: <> "The repository administrator has not yet configured an RDF license."^^ . <> . . "Categorial Grammar and Discourse Representation Theory"^^ . "In this paper it is shown how simple texts that can be parsed \nin a Lambek Categorial Grammar can also automatically be provided \nwith a semantics in the form of a Discourse Representation Structure \nin the sense of Kamp [1981]. The assignment of meanings to texts \nuses the Curry-Howard-Van Benthem correspondence."^^ . "1994" . . . . . . . . . "Reinhard"^^ . "Muskens"^^ . "Reinhard Muskens"^^ . . . . . . "Categorial Grammar and Discourse Representation Theory (PDF)"^^ . . . . . . . . . "cgdrt.pdf"^^ . . . "Categorial Grammar and Discourse Representation Theory (Postscript)"^^ . . . . . . "cgdrt.ps"^^ . . . "Categorial Grammar and Discourse Representation Theory (Image (PNG))"^^ . . . . . . "preview.png"^^ . . . "Categorial Grammar and Discourse Representation Theory (Image (PNG))"^^ . . . . . . "preview.png"^^ . . . "Categorial Grammar and Discourse Representation Theory (Indexer Terms)"^^ . . . . . . "indexcodes.txt"^^ . . "HTML Summary of #4708 \n\nCategorial Grammar and Discourse Representation Theory\n\n" . "text/html" . . . "Computational Linguistics" . . . "Semantics" . . . "Logic" . .