text:
main-content

## Swipe om te navigeren naar een ander artikel

01-10-2010 | Uitgave 8/2010 Open Access

# Gender differences in health-related quality-of-life are partly explained by sociodemographic and socioeconomic variation between adult men and women in the US: evidence from four US nationally representative data sets

Tijdschrift:
Quality of Life Research > Uitgave 8/2010
Auteurs:
Dasha Cherepanov, Mari Palta, Dennis G. Fryback, Stephanie A. Robert
Belangrijke opmerkingen

## Introduction

There are well-documented gender differences in health and health behaviors as reflected in various measures of morbidity, mortality and health care utilization [ 13]. In 2002, age-adjusted death rates for 8 out of 10 leading causes of death in the United States were greater for men than for women, and men were more likely to suffer from chronic conditions that are more severe [ 1, 2, 4]. Men have more life-threatening chronic diseases, including coronary heart disease, cancer, cerebrovascular disease, emphysema, cirrhosis of the liver, kidney disease and atherosclerosis, while women have higher rates of chronic disabling disorders [ 3]. Women are more likely to suffer from autoimmune and rheumatologic disorders and from other non-life-threatening diseases, such as anemia, thyroid conditions, gallbladder conditions, migraines, arthritis and eczema [ 3]. Women are also more likely to experience depressive and anxiety disorders while men more commonly experience antisocial behavior, substance abuse and suicide [ 13]. Differences in morbidity and mortality between men and women create a complex relationship between gender and health.
Preference scored, self-reported health-related quality-of-life (HRQoL) indexes are widely used to summarize the overall health of individuals or groups and to estimate quality-adjusted life-years for use in cost-effectiveness analyses [ 5, 6]. Although men may seem less healthy than women based on their lower life expectancy at all ages and a greater likelihood of suffering from life-threatening diseases, several studies have found women to have lower HRQoL scores than men [ 5, 79]. However, the evidence to date is not clear, because population-based analyses of HRQoL more often control for potential confounding by gender than study gender as an independent variable. No study has systematically examined the relationship of gender and HRQoL across surveys and measures.
Research on HRQoL and more simple measures of self-reported health status demonstrate that self-rated health differs across gender and other sociodemographic and socioeconomic status (SES) characteristics, such as race, marital status, education and income [ 6, 7, 1013]. Liu and Umberson (2008) found self-reported health of those widowed, divorced and separated to be poor relative to those who are married, especially among women [ 12]. The percentage of women who are married decreases with age and is lower than that of men after age 45 [ 15]. Moreover, HRQoL varies significantly by SES [ 13], and it is well known that women have lower individual income than men [ 14]. Hence, gender differences in HRQoL may be partly due to differences in sociodemographic and SES factors.
Several publicly available, nationally representative surveys of HRQoL present an opportunity to examine the consistency of gender difference in HRQoL. Each survey utilized at least one of five commonly used HRQoL indexes, the Short Form 6 dimension (SF-6D) [ 16, 17], EuroQol 5 dimension (EQ-5D) [ 18], the Health Utilities Index Mark 2 (HUI2) [ 20] and Mark 3 (HUI3) [ 21] and the Quality of Well-Being Scale Self-Administered form (QWB-SA) [ 22, 23], and each index, except for the QWB-SA, was used by at least two different surveys. Each survey also collected information on respondent sociodemographic and SES characteristics.
In this study, parallel analyses within each dataset are performed, as well as analyses that pool the surveys. The following hypotheses are tested: (1) women report lower HRQoL than men on the five HRQoL indexes, and (2) differences in sociodemographic and SES characteristics between men and women explain gender differences in HRQoL.

## Methods

### Measures

The five health indexes, SF-6D, EQ-5D, HUI2, HUI3 and QWB-SA, are preference-based generic HRQoL measures anchored on a cardinal scale by 0 (dead) and 1 (full health). The EQ-5D, HUI2 and HUI3 allow health states with utilities less than zero (worse than dead). Although the five indexes are assumed to be measuring the same concept of health on the same theoretical scale, they in fact differ in construction, in coverage of health domains and in their numerical ranges.
The SF-6D index was developed as a summary utility scale based on items from the SF-36v2 TM and SF-12v2 TM (a subset of SF-36v2 TM) questionnaires [ 16, 17]. It refers to health in the “past 4 weeks” and covers six health domains: physical function, role limitation, social function, pain, mental health and vitality. The SF-6D index produces single summary utility scores ranging from 0.35 to 1.0. In this study, the SF-12v2 TM version of SF-6D is used.
The EuroQoL EQ-5D refers to health “today” and incorporates five domains of health, mobility, self-care, usual activities, pain/discomfort and anxiety/depression. This index produces summary utility scores that range from −0.11 to 1 [ 18]. US weights are used in this study [ 19].
The HUI2 and HUI3 indexes refer to health “in the past week.” HUI2 has six domains (sensation, mobility, emotion, cognition, self-care, pain), and HUI3 has eight domains (vision, hearing, speech, ambulation, dexterity, emotion, cognition, pain) for which data are collected using the proprietary Health Utilities Index questionnaire [ 20, 21]. Summary utility scores range from −0.03 to 1.0 for HUI2 and from −0.36 to 1.0 for HUI3.
The QWB-SA index refers to the past three days and covers four domains: mobility/self-care, physical activity, self-care/usual activity and acute/chronic symptoms [ 22, 23]. The QWB-SA produces a summary utility score ranging from 0.09 to 1.0.

### Data and variables

These analyses use four publicly available data sets that were collected during similar time frames and contain HRQoL measures of interest as described in Table  1. All four data sets contain survey weights for producing estimates generalizable to the non-institutionalized adult population in the United States. All participants gave written informed consent at the inception of each of the four surveys. The use of these publically available data sets for this study was approved by the University of Wisconsin-Madison Health Sciences Institutional Review Board.
Table 1
Descriptions of four US representative surveys

USVEQ
MEPS
NHMS
JCUSH
June–October 2002
Full year of 2003
June 2005–August 2006
November 2002–March 2003
PAPI
SAQ
CATI
CATI
Age of respondents
18+ years old
18–90 years old
35–89 years old
18+ years old
No. of US respondents (proxy, non-proxy)
4,048
22,684
3,844
5,183
No. of US respondents a (non-proxy, ages 35–89, Blacks + Whites only)
2,471 (includes 719 non-Hispanic Blacks, 1,752 Hispanics and Whites)
13,195 (includes 38 Hispanic Blacks, 2,582 Hispanic Whites)
3,648 (includes 23 Hispanic Blacks, 47 Hispanic Whites)
3,186 (includes 3 Hispanic Blacks, 59 Hispanic Whites)
Response rate (proxy, non-proxy)
59%
65%
56%
50% b
HRQoL measures
SF6D-SF36v2

X

SF6D-SF12v2

X
X*

QWB-SA

X

EQ-5D
X
X
X

HUI2
X

X

HUI3
X

X
X
USVEQ US Valuation of the EuroQol EQ-5D health states survey; MEPS Medical expenditure panel survey; NHMS National health measurement study; JCUSH Joint Canada/US survey of health (JCUSH); PAPI Paper-and-pencil in face-to-face interview; SAQ Self-administered questionnaire; CATI Computer-assisted telephone interview
* The SF-12v2 TM is a subset of the SF-36v2 TM, and thus the SF6D-SF12v2 can be scored in NHMS
aThe number of US respondents represents the analytical samples used from each of the four surveys
bThis is the United States response rate (excluding Canada)
The US Valuation of the EuroQol EQ-5D Health States Survey (USVEQ) produced a nationally representative sample from civilian non-institutionalized residents of ages 18 and older within the 50 US states and the District of Columbia [ 19]. Data were collected between June and October of 2002. It was administered via paper-and-pencil in face-to-face interviews (PAPI). Survey weights were post-stratified by age (18+), gender and race (Hispanic, non-Hispanic black and other).
The Medical Expenditure Panel Survey (MEPS) has been administered annually to the US non-institutionalized population ages 18–90 years old (for confidentiality purposes, MEPS coded all ages >85 as ‘85’) since 1996 to obtain information on health care utilization and expenditures via mailed self-administered questionnaire (SAQ) [ 25]. Survey weights were post-stratified by six variables (race/ethnicity: Hispanic, black non-Hispanic, and other; sex; age; poverty status; census region; metropolitan statistical area). The 2003 MEPS data are used in the current study to best match the time frame of the other nationally representative data sets.
The National Health Measurement Study (NHMS) is a nationally representative computer-assisted telephone interview (CATI) survey of non-institutionalized adults between the ages of 35 and 89 residing in the continental US [ 6]. The survey was conducted between June 2005 and August 2006. The survey weights were post-stratified by gender, race (black, white and other) and age (35–44, 45–66, 65+).
The Joint Canada/US Survey of Health (JCUSH) is a cross-sectional random-digit-dialed telephone survey conducted in both Canada and the United States, administered via a CATI [ 24]. Data collection took place between November 2002 and March 2003. The study included people ages 18 and over in both countries and excluded people who were institutionalized or living in United States or Canadian territories. JCUSH survey weights were post-stratified by age (18–44, 44–64, 65+) and gender.
The current analyses target non-proxy US respondents whose ages were between 35 and 89 years and who reported their race/ethnicity as either white/Caucasian or black/African American (Table  1). The ‘other’ race/ethnicity category was excluded from our analyses since these data contained too few individuals from each of these many racial and ethnic subgroups of the US population. NHMS, JCUSH and MEPS specified their race categories as white/Caucasian and black/African American while race categories in USVEQ were black/African American (non-Hispanic), white (non-Hispanic) and Hispanic/Latino. For comparability with the other surveys, we coded Hispanic/Latino from USVEQ as white/Caucasian. The majority (at least 67%) of Hispanic respondents in the other three studies self-reported themselves as white.
Our analyses adjusted for sociodemographic and SES variables. The variables in the different data sets were coded as similarly as possible. Table  2 describes the coding and shows the distributions of the resulting independent variables by dataset and gender.
Table 2
Weighted proportions (shown in percents) of sample characteristics by dataset and gender
Data (year)
USVEQ (2002)
MEPS (2003)
NHMS (2005–2006)
JCUSH (2002–2003)
Census 2000 Proportions
Gender
Women
Men
Total
Women
Men
Total
Women
Men
Total
Women
Men
Total
Gender (%)
52.3
47.7

52.5
47.5

53.5
46.5

54.0
46.0

Age group
35–44
33.3
31.8
32.6
28.0
30.5
29.2
32.6
28.7
30.8
29.5
31.5
30.4
45–54
25.6
28.5
27.0
26.5
27.9
27.1
24.8
22.4
23.7
26.6
29.0
27.7
55–64
17.2
19.1
18.1
19.4
20.1
19.7
20.0
21.1
20.5
18.6
18.8
18.7
65–74
12.3
12.4
12.4
13.4
12.7
13.0
13.2
15.8
14.4
15.2
11.6
13.5
74–89
11.5
8.1
9.9
12.7
8.9
10.9
9.4
12.0
10.6
10.2
9.0
9.6
Total N (unweighted)
2,471

13,195

3,648

3,186

Race a
Black
11.8
9.7
10.8
11.9
10.5
11.2
12.5
10.3
11.4
14.5
12.3
13.5

White
88.2
90.3
89.2
88.1
89.5
88.8
87.5
89.7
88.6
85.5
87.7
86.5

Marital status
Never married/single
5.5
8.8
7.1
9.0
11.6
10.3
7.3
6.5
6.9
8.0
8.6
8.3
9.6*
Widowed/divorced/separated
35.4
16.8
26.5
32.2
18.5
25.7
23.9
12.8
18.8
29.2
13.4
21.9
26.1*
Married/living with partner
59.1
74.4
66.4
58.8
69.9
64.1
68.7
80.7
74.3
62.8
78.0
69.8
64.3*
Education
Less than high school (HS)
18.4
18.7
18.6
18.3
18.9
18.6
8.8
6.8
7.9
9.8
7.4
8.7
17.8**
34.8
32.0
33.5
35.8
32.1
34.0
28.9
28.7
28.8
38.7
32.2
35.7
29.6**
Some post-HS education
24.9
25.4
25.2
22.5
20.0
21.3
24.7
19.4
22.2
15.3
14.6
15.0
28.0**
College degree or higher
21.8
23.9
22.8
23.4
29.0
26.1
37.6
45.1
41.1
36.2
45.9
40.7
24.6**
Household income b

Lowest income level
28.6
19.5
24.1
9.2
7.0
8.2
12.7
9.2
11.0
16.9
10.1
13.7
21.3***
2nd lowest income level
28.9
27.3
28.1
14.1
10.1
12.2
16.1
14.0
15.1
22.3
16.4
19.5
18.2***
3rd lowest income level
28.6
32.4
30.5
55.0
58.5
56.7
34.3
39.1
36.6
35.1
40.4
37.6
35.4***
Highest income level
13.9
20.8
17.3
21.7
24.4
23.0
36.9
37.7
37.3
25.6
33.1
29.2
25.1***
In regression analyses, marital status, education, and household income were adjusted to Census 2000 proportions ( www.factfinder.census.gov) that include
* All races, ages 35+ (never married; separated/widowed/divorced; married, spouse present)
** Whites and blacks only, ages 25+ (less than 9th grade/9–10th grade, no diploma; high school graduate (includes equivalency); some college, no degree/Associate degree; Bachelor’s degree/graduate or professional degree)
*** Whites and blacks only, ages 35+ (<$20,000;$20,000–$34,999;$35,000–$74,999; ≥$75,000); All Census 2000 proportions exclude Alaska, Hawaii and Puerto Rico
aIn regression analyses, race was adjusted to average proportions across datasets (Black 12%; White 88%); Income levels by dataset: USVEQ (<$20,000,$20,000–$40,000,$40,001–$75,000, ≥$75,001), MEPS family income (<$20,000,$20,000–$34,999,$35,000–$74,999, ≥$75,000), NHMS (<$20,000,$20,000–$34,999,$35,000–$74,999, ≥$75,000), JCUSH (<$20,000,$20,000–$40,000,$40,001–$80,000, ≥$80,001)
The datasets differed only slightly in coding of the income variable. All studies but MEPS measured total household income, whereas MEPS measured income as family income in terms of percent of the poverty line based on number of family members. According to Department of Health and Human Services Poverty Guidelines, income as percent of the Federal Poverty Line (FPL), is classified as poor: <100%, near poor: 100–125%, low: 125–200%, middle: 200–400% and high: 400% or greater. FPL varies according to number of members in a family [ 26]. The number of family members and midpoints of FPL percentage ranges were used to convert the MEPS income classifications into dollar values. These were grouped into four income categories comparable to those of the other three studies.
The categorization of age was the same in all four data sets. Marital status and education questions had variations in phrasing and answer options. Categories were created to be relatively similar across surveys.

### Analyses

We fit survey-weighted least squares (WLS) regression models separately for each data set with HRQoL scores as outcome variables. Gender, age and race (model 1) were included in all models; and marital status (model 2), education (model 3) and income (model 4), were added one at a time and simultaneously (model 5). All covariates were modeled as indicator variables. Gender differences used women as the reference category by coding men as “1” and women as “0”.
Estimates of gender difference were standardized via model-based adjustment to the marginal Census 2000 proportions ( www.factfinder.census.gov) of variables not already used for post-stratification as shown in Table  2. This was achieved by including interactions of gender with these sociodemographic and SES variables centered at their percentage representation in the Census.
Additional analyses were conducted by pooling data sets: MEPS and NHMS (for SF-6D); USVEQ, MEPS and NHMS (for EQ-5D); JCUSH, NHMS and USVEQ (for HUI3); and USVEQ and NHMS (for HUI2). In the WLS analyses of the pooled data, each dataset was specified as a sampling stratum, and indicator variables for the particular data sets were included in the models.
All analyses were conducted using SAS/STAT ® System for Windows (version 9.1) applying procedures PROC SURVEYFREQ, SURVEYMEANS and SURVEYREG, which incorporated survey weights to produce US nationally representative estimates (Copyright 2002–2003 SAS Institute Inc., Cary, NC, USA).

## Results

### Respondent characteristics

Table  2 shows the weighted sample characteristics underlying each dataset separately for women and men. Based on all four surveys, the distributions of marital status and income were different for men and women, yet education distributions were similar. Notably, a greater proportion of women than men reported being widowed, divorced or separated while more men reported being married or living with a partner. All four surveys showed a higher proportion of women reporting the two lowest levels of income while a greater proportion of men reported having the two highest levels of income.

### Results from regression analyses

Gender differences from multivariable WLS regressions from the four studies and pooled analyses are presented in Table  3 and are shown graphically in Fig.  1. The table summarizes gender parameter estimates from five WLS regression models with women as the reference category. All estimates, except for fully adjusted HUI3, were positive, indicating men on average have better HRQoL than women. Gender differences in HRQoL were statistically significant ( P ≤ .05) for most HRQoL measures when only age and race (model 1) were in the model with the exception of EQ-5D and HUI3 in USVEQ ( P ≤ .08). Adjustment for marital status (model 2) or income (model 4) tended to result in the greatest reductions in the gender difference. The magnitude of gender differences for SF-6D in MEPS was larger than in NHMS. Adjustment for income greatly reduced the gender difference for SF-6D in NHMS, and statistical significance of gender was lost in the models that included income (models 4 and 5). Gender differences in EQ-5D from MEPS and NHMS were nearly identical across models until income was added into the model. In both NHMS and USVEQ, gender differences in EQ-5D decreased when adjusted for marital status or income. The magnitudes of gender differences in HUI2 and HUI3 were smaller in NHMS than in USVEQ when adjusted for education and all three sociodemographic and SES variables at once (marital status, education, income). The gender differences were most prominent for HUI2 in USVEQ, SF-6D in MEPS, and QWB-SA in NHMS. EQ-5D showed the smallest gender differences. HUI3 was the only measure that had a negative but statistically non-significant gender estimate after all adjustments in both JCUSH and NHMS. Figure  1 illustrates the results seen in Table  3 for each HRQoL measure across the surveys where it was obtained.
Table 3
HRQoL measures regressed (WLS) on gender (controlling for age, race, marital status, education and income) with women as the reference category
Gender parameter estimates
SF-6D
EQ-5D
HUI2
HUI3
QWB-SA
Estimate
SE
Estimate
SE
Estimate
SE
Estimate
SE
Estimate
SE
USVEQ dataset
1: age, race
0.016
0.009
0.024**
0.008
0.023
0.013
2: age, race, marital status
0.009
0.009
0.014
0.008
0.010
0.013
3: age, race, education
0.016*
0.009
0.024**
0.008
0.023
0.013
4: age, race, income
0.008
0.009
0.013
0.008
0.012
0.013
5: all covariates
0.008
0.009
0.012
0.009
0.011
0.013
MEPS dataset
1: age, race
0.029***
0.002
0.017***
0.003
2: age, race, marital status
0.025***
0.003
0.013***
0.003
3: age, race, education
0.028***
0.003
0.016***
0.003
4: age, race, income
0.027***
0.003
0.017***
0.004
5: all covariates
0.022***
0.003
0.013***
0.004
NHMS dataset
1: age, race
0.023***
0.007
0.019**
0.007
0.024**
0.008
0.023*
0.012
0.030***
0.008
2: age, race, marital status
0.015*
0.007
0.014
0.008
0.015
0.009
0.009
0.013
0.024**
0.008
3: age, race, education
0.020*
0.008
0.013
0.009
0.018
0.011
0.014
0.016
0.027**
0.009
4: age, race, income
0.012
0.008
0.010
0.010
0.013
0.012
0.011
0.017
0.023**
0.009
5: all covariates
0.007
0.009
0.005
0.011
0.006
0.013
−0.002
0.018
0.021*
0.010
JCUSH dataset
1: age, race
0.024**
0.008
2: age, race, marital status
0.013
0.009
3: age, race, education
0.008
0.012
4: age, race, income
0.004
0.011
5: all covariates
−0.008
0.014
Pooled datasets
1: age, race
0.028***
0.002
0.018***
0.003
0.024***
0.006
0.024***
0.007
2: age, race, marital status
0.023***
0.003
0.014***
0.003
0.017**
0.007
0.012
0.007
3: age, race, education
0.027***
0.003
0.016***
0.003
0.023**
0.007
0.017*
0.008
4: age, race, income
0.024***
0.003
0.013***
0.003
0.013
0.007
0.007
0.008
5: all covariates
0.020***
0.003
0.010***
0.004
0.010
0.008
0.000
0.009
The table summarizes regression parameter estimates for gender
***  P ≤ .001; **  P ≤ .01; *  P ≤ .05; ‡  P ≤ .08
Pooled analyses are shown in Table  3 and are plotted in Fig.  1. These analyses confirmed that adjusting for marital status or income had the greatest impact on the gender difference in HRQoL. Positive gender parameter estimates were statistically significant in all models for SF-6D and EQ-5D, although these results were mostly driven by the MEPS. The HUI2 and HUI3 had statistically significant gender estimates up to model 3 (which included education). In model 2 (including marital status), gender differences in HUI3 had a P ≤ .08. Addition of income or all covariates at once in the model decreased precision of the gender estimates, and generally made the statistically significant difference disappear. HUI3 was the only measure that showed no gender differences after all adjustments in the pooled analysis. Only SF-6D and QWB-SA retained gender difference estimate of at least 0.02.

## Discussion

This study confirms that women self-report worse health than men on five commonly used HRQoL indexes. This difference in HRQoL appears to be explained in large part by differences in sociodemographic and SES characteristics between men and women in the US population. Large differences in HRQoL by SES have been previously documented [ 13]. The lower average income of women appears to account for much of their disadvantage in HRQoL.
The gender-associated differences seen in HRQoL depend somewhat on the particular HRQoL index used. The estimates range from 0.02 to 0.03 (higher HRQoL for men) without adjustment and from −0.01 to 0.03 with adjustment for marital status, education and income. Only the SF-6D and QWB-SA displayed magnitudes of gender differences that approached 0.03, considered substantively important for preference-based HRQoL indexes [ 10, 27, 28, 34].
The gender differences on all HRQoL indexes followed parallel trajectories of change with adjustment for sociodemographic and SES variables. Taking age and race differences into account generally did not explain the gender difference in HRQoL and produced estimates that were quite similar across measures (except somewhat higher for SF-6D and lower for EQ-5D). Once further adjustments for marital status, education and income were taken into account, gender differences became small on most HRQoL measures. Taking income differentials into account resulted in estimates that were again quite consistent across measures with a few exceptions. EQ-5D retained a statistically significant gender difference in the pooled analysis due to the large sample size of MEPS, although the magnitude of the difference was similar to the non-significant differences in other measures. In contrast, after controlling for income or marital status or all covariates simultaneously, the gender difference in SF-6D remained moderate and statistically significant in MEPS and pooled analyses, as did the difference in QWB-SA from NHMS.
Several circumstances may have contributed to the greater and persistent gender differences in SF-6D and QWB-SA. It is well known that the five HRQoL measures differ in construction (e.g., HRQoL domains, time frames, elicitation methods and scoring equations) and distributional properties (e.g., ceiling/floor effects, numerical range), although they purport to represent the same evaluation of a given level of health [ 6]. The observed gender differences in HRQoL reported here may then be in part an artifact of the particular HRQoL index used. For example, SF-6D and QWB-SA have minimal ceiling effects compared to the other three indexes [ 6], which may lead to these two measures identifying gender differences between relatively healthy men and women. The QWB-SA is also the only measure that incorporates in its summary score a list of 58 acute/chronic symptoms and health conditions, and such symptoms may differ by gender. The fact that the remaining gender difference in SF-6D after adjustment for marital status and income (in the pooled analysis) arose almost entirely from MEPS and not from the NHMS raises the possibility that differences in adjustment variable categorization may have led to differences in results, such as differences in measurement of the income variable in MEPS.
MEPS and NHMS also differ in mode of administration. Hanmer et al. (2007) [ 7] showed that self-administered surveys (e.g., MEPS) yield lower HRQoL scores than telephone surveys (e.g., NHMS) on the EQ-5D, Visual Analog Scale, HUI3 and general self-rated health question. Hays et al. (2009) [ 29] found HRQoL scores are more positive for phone administration following mail administration with differences between modes: 0.06 (SF-6D), 0.03 (QWB-SA), 0.08 (EQ-5D), 0.04 (HUI2) and 0.10 (HUI3). Further analyses (not shown) revealed that distributions on domains of SF-6D in MEPS and NHMS are similar except for the mental health domain. Greater proportions of both men and women reported lower levels of mental health in MEPS than in NHMS; however, the proportions differed more for women than men between the two datasets. This may indicate that differences in SF-6D results between MEPS and NHMS may be related to a greater mode effect among women on SF-6D.
Alternatively, persistent gender differences in SF-6D and QWB-SA may reflect unique health variation captured by these indexes but not by EQ-5D, HUI2 or HUI3, or gender biases in item responses. Fleishman and Lawrence (2003) found, based on the MEPS data, that some questions on SF-12v2 TM are prone to differential item functioning (DIF) between the genders, i.e., different responses to the questions by men and women having the same underlying health [ 30]. In particular, the two questions that are used to estimate the mental heath component of SF-6D (“felt downhearted”, “had energy”) were found to have DIF by gender [ 17, 30, 31]. Fleishman and Lawrence (2003) showed that adjusting for DIF generally reduced gender differences in mental health [ 30].
HUI3 in NHMS and JCUSH was the only HRQoL index that showed a reverse direction of the gender difference, though not statistically significant, with simultaneous adjustment for age, race, marital status, education and income. HUI3 was also more affected by adjustments for SES than were other measures. The relatively greater sensitivity to SES adjustments on HUI3 is consistent with findings of Robert et al. (2009) [ 13] who showed that income-associated disparities appear wider for the HUI3 than for SF-6D or EQ-5D.
There may be several reasons for minor differences in results between the studies. Random variation, differences in sampling and mode effects (JCUSH and NHMS were phone surveys; MEPS and USVEQ were self-administered) may have led to such differences [ 7]. Our analysis aims to represent the sociodemographic and SES mix of the US population and may be smaller or larger in certain subgroups or in populations with a different sociodemographic and SES mix. Future research on such interactions is warranted. Furthermore, the analysis adjusted the results to marginal percentages in age, race and socioeconomic subgroups, but not to percentages in subgroups formed by 2 or 3-way cross-tabulation of these variables, which may also have been affected by response biases.
Small gender differences in HRQoL that persist even after adjustments for available sociodemographic and SES characteristics indicate either that this variation has been incompletely measured, or that other factors are contributing to gender differences in HRQoL. We may not be measuring accurately the full distribution of marital status, education and income, especially as we have collapsed these variables in our attempt to achieve consistency across data sets. In addition, it may be that dynamics of marital status and income over the life course contribute significantly to gender differences in HRQoL—dynamic effects that our cross-sectional analyses cannot detect. Clearly, age, race, marital status, education and income are likely not the only sociodemographic and SES variables that contribute to HRQoL differences between men and women.
Our analysis focuses on whether there are gender differences in HRQoL and whether these differences are related to sociodemographic and SES differentials between men and women. Alternatively, the analysis could have examined whether other measures of self-perceived health (e.g., general self-rated health question, symptoms/conditions and morbidity indexes) explain gender differences in HRQoL. Such analyses would aim to answer different questions and may lead to different conclusion regarding gender differences. Several considerations would affect the interpretation of analyses attempting to adjust for such measures, including measurement error or bias in the adjustment variables themselves. HRQoL measures have been developed to capture the multiple dimensions of the health experience beyond the presence of disease. However, examining gender differences in HRQoL among men and women with the same illness or disease may be a fruitful direction of future research.
This study has several limitations. These analyses are based on cross-sectional data so it was not possible to assess gender differences in changes in HRQoL over time. The inability to consistently control for household or family size in measuring household income may be a weakness of this study. Additionally, this study is based on a non-institutionalized sample and at least two institutionalized segments of the US population, those who are hospitalized or in nursing homes, are likely to have the worst HRQoL than people in our study and are predominantly women [ 32, 33]. Due to sample age and race restrictions in the analyses, only community-residing 35–89-year-old black and white US adults are represented in the results.
The primary strength of the study is the simultaneous use of four recently conducted, large nationally representative surveys among US adults and several commonly used preference-based measures of HRQoL. To further understand the scope of gender differences in HRQoL, it is important to conduct future research on gender and HRQoL in other subpopulations of the United States, including residents ages <35, other racial subgroups of the population and people living in institutions. Incorporating longitudinal data would allow an assessment of how aging affects changes in HRQoL in men and women. It is also important to assess whether gender differences in HRQoL are larger in some subgroups of the population.

## Conclusion

This study of gender differences in five commonly used measures of HRQoL from four nationally representative studies indicated that US women on average have slightly lower self-reported HRQoL than men. The HRQoL gap is largely explained by sociodemographic and SES differentials between men and women. All five measures of HRQoL showed similar gender differences prior to sociodemographic and SES adjustments and relatively similar patterns with adjustment. Income and marital status contributed the most to explaining gender differences in HRQoL across measures. Our findings underscore the impact of socioeconomic disparities on the well-being of women and point to the importance of considering such disparities prior to attributing poor HRQoL in women to other gender-related factors.

## Acknowledgments

This research was supported by a grant to the University of Wisconsin, Madison from the National Institute on Aging (P01-AG020679), and a grant to University of California, Los Angeles, and the RAND Corporation, Santa Monica, CA, from the Agency for Healthcare Research and Quality for a postdoctoral fellowship in Health Services Research (T32 HS000046).

### Open Access

Open AccessThis is an open access article distributed under the terms of the Creative Commons Attribution Noncommercial License ( https://creativecommons.org/licenses/by-nc/2.0), which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited.

## Onze productaanbevelingen

### BSL Podotherapeut Totaal

Binnen de bundel kunt u gebruik maken van boeken, tijdschriften, e-learnings, web-tv's en uitlegvideo's. BSL Podotherapeut Totaal is overal toegankelijk; via uw PC, tablet of smartphone.

Literatuur
Over dit artikel

Naar de uitgave


text:
# Integer expression

## Homework Statement

Prove that the expression $$\frac{a(a^2 + a)}{3}$$ is an integer for all integers $$\geq 1$$

## The Attempt at a Solution

$$a(a^2 + a ) = 3q + r$$

r can be:

$$r = 0,1,2$$

for r = 0

$$\frac{a(a^2 + a)}{3} = q$$

q is an integer by the division algorithm.

When I try this attempt with 3q+1 and 3q+2 I can't get it to work.

## The Attempt at a Solution

This is not true for all positive integers. For example, setting a = 1 gives 2/3.

Sorry there is a correction $$\frac{a^3 -a}{3}$$

gabbagabbahey
Homework Helper
Gold Member
Sorry there is a correction $$\frac{a^3 -a}{3}$$

You might want to factor $a^3 -a$, and show that for all integers $a\geq1$, one of the factors will be divisible by 3.

Hurkyl
Staff Emeritus
Gold Member

## The Attempt at a Solution

$$a^3 - a = 3q + r$$

r can be:

$$r = 0,1,2$$

for r = 0

$$\frac{a^3 - a}{3} = q$$

q is an integer by the division algorithm.
Where did q and r come from? Whenever you introduce new variables, you need to say what they are, and why they should have the properties you say they have. You need to say something like "By the division algorithm, we can select integers q and r such that a^3 - a = 3q + r, where 0 <= r < 3". If you don't explain the introduction of new variables, then your work is just nonsense.

Yes, I was able to figure out what you meant, but that's irrelevant; it would be completely analogous to saying "me food want" in your English classes.

When I try this attempt with 3q+1 and 3q+2 I can't get it to work.
Of course not. If r=1 or r=2, then (a^3-a)/3 is not an integer. That's what 'remainder' means, right? And r is supposed to be a remainder?

Fermat's little theorem: a^2 Mod 3 = 1 if a is not a multiple of 3. So we always have that a^3 = a Mod 3.

format: plain


text:
# Reinforcement Learning¶

Installation size

Reinforcement learning dependencies include large packages such as torch, which should be explicitly requested during ./setup.sh -i by answering "y" to the question "Do you also want dependencies for freqai-rl (~700mb additional space required) [y/N]?". Users who prefer docker should ensure they use the docker image appended with _freqairl.

## Background and terminology¶

### What is RL and why does FreqAI need it?¶

Reinforcement learning involves two important components, the agent and the training environment. During agent training, the agent moves through historical data candle by candle, always making 1 of a set of actions: Long entry, long exit, short entry, short exit, neutral). During this training process, the environment tracks the performance of these actions and rewards the agent according to a custom user made calculate_reward() (here we offer a default reward for users to build on if they wish details here). The reward is used to train weights in a neural network.

A second important component of the FreqAI RL implementation is the use of state information. State information is fed into the network at each step, including current profit, current position, and current trade duration. These are used to train the agent in the training environment, and to reinforce the agent in dry/live (this functionality is not available in backtesting). FreqAI + Freqtrade is a perfect match for this reinforcing mechanism since this information is readily available in live deployments.

Reinforcement learning is a natural progression for FreqAI, since it adds a new layer of adaptivity and market reactivity that Classifiers and Regressors cannot match. However, Classifiers and Regressors have strengths that RL does not have such as robust predictions. Improperly trained RL agents may find "cheats" and "tricks" to maximize reward without actually winning any trades. For this reason, RL is more complex and demands a higher level of understanding than typical Classifiers and Regressors.

### The RL interface¶

With the current framework, we aim to expose the training environment via the common "prediction model" file, which is a user inherited BaseReinforcementLearner object (e.g. freqai/prediction_models/ReinforcementLearner). Inside this user class, the RL environment is available and customized via MyRLEnv as shown below.

We envision the majority of users focusing their effort on creative design of the calculate_reward() function details here, while leaving the rest of the environment untouched. Other users may not touch the environment at all, and they will only play with the configuration settings and the powerful feature engineering that already exists in FreqAI. Meanwhile, we enable advanced users to create their own model classes entirely.

The framework is built on stable_baselines3 (torch) and OpenAI gym for the base environment class. But generally speaking, the model class is well isolated. Thus, the addition of competing libraries can be easily integrated into the existing framework. For the environment, it is inheriting from gym.env which means that it is necessary to write an entirely new environment in order to switch to a different library.

### Important considerations¶

As explained above, the agent is "trained" in an artificial trading "environment". In our case, that environment may seem quite similar to a real Freqtrade backtesting environment, but it is NOT. In fact, the RL training environment is much more simplified. It does not incorporate any of the complicated strategy logic, such as callbacks like custom_exit, custom_stoploss, leverage controls, etc. The RL environment is instead a very "raw" representation of the true market, where the agent has free will to learn the policy (read: stoploss, take profit, etc.) which is enforced by the calculate_reward(). Thus, it is important to consider that the agent training environment is not identical to the real world.

## Running Reinforcement Learning¶

Setting up and running a Reinforcement Learning model is the same as running a Regressor or Classifier. The same two flags, --freqaimodel and --strategy, must be defined on the command line:

freqtrade trade --freqaimodel ReinforcementLearner --strategy MyRLStrategy --config config.json

where ReinforcementLearner will use the templated ReinforcementLearner from freqai/prediction_models/ReinforcementLearner (or a custom user defined one located in user_data/freqaimodels). The strategy, on the other hand, follows the same base feature engineering with feature_engineering_* as a typical Regressor. The difference lies in the creation of the targets, Reinforcement Learning doesn't require them. However, FreqAI requires a default (neutral) value to be set in the action column:

    def set_freqai_targets(self, dataframe, **kwargs):
"""
*Only functional with FreqAI enabled strategies*
Required function to set the targets for the model.
All targets must be prepended with & to be recognized by the FreqAI internals.

More details about feature engineering available:

:param df: strategy dataframe which will receive the targets
usage example: dataframe["&-target"] = dataframe["close"].shift(-1) / dataframe["close"]
"""
# For RL, there are no direct targets to set. This is filler (neutral)
# until the agent sends an action.
dataframe["&-action"] = 0

Most of the function remains the same as for typical Regressors, however, the function above shows how the strategy must pass the raw price data to the agent so that it has access to raw OHLCV in the training environment:

    def feature_engineering_standard(self, dataframe, **kwargs):
# The following features are necessary for RL models
dataframe[f"%-raw_close"] = dataframe["close"]
dataframe[f"%-raw_open"] = dataframe["open"]
dataframe[f"%-raw_high"] = dataframe["high"]
dataframe[f"%-raw_low"] = dataframe["low"]

Finally, there is no explicit "label" to make - instead it is necessary to assign the &-action column which will contain the agent's actions when accessed in populate_entry/exit_trends(). In the present example, the neutral action to 0. This value should align with the environment used. FreqAI provides two environments, both use 0 as the neutral action.

After users realize there are no labels to set, they will soon understand that the agent is making its "own" entry and exit decisions. This makes strategy construction rather simple. The entry and exit signals come from the agent in the form of an integer - which are used directly to decide entries and exits in the strategy:

    def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:

enter_long_conditions = [df["do_predict"] == 1, df["&-action"] == 1]

if enter_long_conditions:
df.loc[
reduce(lambda x, y: x & y, enter_long_conditions), ["enter_long", "enter_tag"]
] = (1, "long")

enter_short_conditions = [df["do_predict"] == 1, df["&-action"] == 3]

if enter_short_conditions:
df.loc[
reduce(lambda x, y: x & y, enter_short_conditions), ["enter_short", "enter_tag"]
] = (1, "short")

return df

def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
exit_long_conditions = [df["do_predict"] == 1, df["&-action"] == 2]
if exit_long_conditions:
df.loc[reduce(lambda x, y: x & y, exit_long_conditions), "exit_long"] = 1

exit_short_conditions = [df["do_predict"] == 1, df["&-action"] == 4]
if exit_short_conditions:
df.loc[reduce(lambda x, y: x & y, exit_short_conditions), "exit_short"] = 1

return df

It is important to consider that &-action depends on which environment they choose to use. The example above shows 5 actions, where 0 is neutral, 1 is enter long, 2 is exit long, 3 is enter short and 4 is exit short.

## Configuring the Reinforcement Learner¶

In order to configure the Reinforcement Learner the following dictionary must exist in the freqai config:

        "rl_config": {
"train_cycles": 25,
"max_training_drawdown_pct": 0.02,
"cpu_count": 8,
"model_type": "PPO",
"policy_type": "MlpPolicy",
"model_reward_parameters": {
"rr": 1,
"profit_aim": 0.025
}
}

Parameter details can be found here, but in general the train_cycles decides how many times the agent should cycle through the candle data in its artificial environment to train weights in the model. model_type is a string which selects one of the available models in stable_baselines(external link).

Note

If you would like to experiment with continual_learning, then you should set that value to true in the main freqai configuration dictionary. This will tell the Reinforcement Learning library to continue training new models from the final state of previous models, instead of retraining new models from scratch each time a retrain is initiated.

Note

Remember that the general model_training_parameters dictionary should contain all the model hyperparameter customizations for the particular model_type. For example, PPO parameters can be found here.

## Creating a custom reward function¶

As you begin to modify the strategy and the prediction model, you will quickly realize some important differences between the Reinforcement Learner and the Regressors/Classifiers. Firstly, the strategy does not set a target value (no labels!). Instead, you set the calculate_reward() function inside the MyRLEnv class (see below). A default calculate_reward() is provided inside prediction_models/ReinforcementLearner.py to demonstrate the necessary building blocks for creating rewards, but users are encouraged to create their own custom reinforcement learning model class (see below) and save it to user_data/freqaimodels. It is inside the calculate_reward() where creative theories about the market can be expressed. For example, you can reward your agent when it makes a winning trade, and penalize the agent when it makes a losing trade. Or perhaps, you wish to reward the agent for entering trades, and penalize the agent for sitting in trades too long. Below we show examples of how these rewards are all calculated:

    from freqtrade.freqai.prediction_models.ReinforcementLearner import ReinforcementLearner
from freqtrade.freqai.RL.Base5ActionRLEnv import Actions, Base5ActionRLEnv, Positions

class MyCoolRLModel(ReinforcementLearner):
"""
User created RL prediction model.

Save this file to freqtrade/user_data/freqaimodels

then use it with:

Here the users can override any of the functions
available in the IFreqaiModel inheritance tree. Most importantly for RL, this
is where the user overrides MyRLEnv (see below), to define custom
calculate_reward() function, or to override any other parts of the environment.

This class also allows users to override any other part of the IFreqaiModel tree.
For example, the user can override def fit() or def train() or def predict()
to take fine-tuned control over these processes.

Another common override may be def data_cleaning_predict() where the user can
take fine-tuned control over the data handling pipeline.
"""
class MyRLEnv(Base5ActionRLEnv):
"""
User made custom environment. This class inherits from BaseEnvironment and gym.env.
Users can override any functions from those parent classes. Here is an example
of a user customized calculate_reward() function.
"""
def calculate_reward(self, action: int) -> float:
# first, penalize if the action is not valid
if not self._is_valid(action):
return -2
pnl = self.get_unrealized_profit()

factor = 100

pair = self.pair.replace(':', '')

# you can use feature values from dataframe
# Assumes the shifted RSI indicator has been generated in the strategy.
rsi_now = self.raw_features[f"%-rsi-period-10_shift-1_{pair}_"
f"{self.config['timeframe']}"].iloc[self._current_tick]

# reward agent for entering trades
if (action in (Actions.Long_enter.value, Actions.Short_enter.value)
and self._position == Positions.Neutral):
if rsi_now < 40:
factor = 40 / rsi_now
else:
factor = 1
return 25 * factor

# discourage agent from not entering trades
if action == Actions.Neutral.value and self._position == Positions.Neutral:
return -1
factor *= 1.5
factor *= 0.5
# discourage sitting in position
if self._position in (Positions.Short, Positions.Long) and \
action == Actions.Neutral.value:
# close long
if action == Actions.Long_exit.value and self._position == Positions.Long:
if pnl > self.profit_aim * self.rr:
factor *= self.rl_config['model_reward_parameters'].get('win_reward_factor', 2)
return float(pnl * factor)
# close short
if action == Actions.Short_exit.value and self._position == Positions.Short:
if pnl > self.profit_aim * self.rr:
factor *= self.rl_config['model_reward_parameters'].get('win_reward_factor', 2)
return float(pnl * factor)
return 0.

### Using Tensorboard¶

Reinforcement Learning models benefit from tracking training metrics. FreqAI has integrated Tensorboard to allow users to track training and evaluation performance across all coins and across all retrainings. Tensorboard is activated via the following command:

cd freqtrade
tensorboard --logdir user_data/models/unique-id

where unique-id is the identifier set in the freqai configuration file. This command must be run in a separate shell to view the output in their browser at 127.0.0.1:6006 (6006 is the default port used by Tensorboard).

### Custom logging¶

FreqAI also provides a built in episodic summary logger called self.tensorboard_log for adding custom information to the Tensorboard log. By default, this function is already called once per step inside the environment to record the agent actions. All values accumulated for all steps in a single episode are reported at the conclusion of each episode, followed by a full reset of all metrics to 0 in preparation for the subsequent episode.

self.tensorboard_log can also be used anywhere inside the environment, for example, it can be added to the calculate_reward function to collect more detailed information about how often various parts of the reward were called:

        class MyRLEnv(Base5ActionRLEnv):
"""
User made custom environment. This class inherits from BaseEnvironment and gym.env.
Users can override any functions from those parent classes. Here is an example
of a user customized calculate_reward() function.
"""
def calculate_reward(self, action: int) -> float:
if not self._is_valid(action):
self.tensorboard_log("invalid")
return -2

Note

The self.tensorboard_log() function is designed for tracking incremented objects only i.e. events, actions inside the training environment. If the event of interest is a float, the float can be passed as the second argument e.g. self.tensorboard_log("float_metric1", 0.23). In this case the metric values are not incremented.

### Choosing a base environment¶

FreqAI provides three base environments, Base3ActionRLEnvironment, Base4ActionEnvironment and Base5ActionEnvironment. As the names imply, the environments are customized for agents that can select from 3, 4 or 5 actions. The Base3ActionEnvironment is the simplest, the agent can select from hold, long, or short. This environment can also be used for long-only bots (it automatically follows the can_short flag from the strategy), where long is the enter condition and short is the exit condition. Meanwhile, in the Base4ActionEnvironment, the agent can enter long, enter short, hold neutral, or exit position. Finally, in the Base5ActionEnvironment, the agent has the same actions as Base4, but instead of a single exit action, it separates exit long and exit short. The main changes stemming from the environment selection include:

• the actions available in the calculate_reward
• the actions consumed by the user strategy

All of the FreqAI provided environments inherit from an action/position agnostic environment object called the BaseEnvironment, which contains all shared logic. The architecture is designed to be easily customized. The simplest customization is the calculate_reward() (see details here). However, the customizations can be further extended into any of the functions inside the environment. You can do this by simply overriding those functions inside your MyRLEnv in the prediction model file. Or for more advanced customizations, it is encouraged to create an entirely new environment inherited from BaseEnvironment.

Note

Only the Base3ActionRLEnv can do long-only training/trading (set the user strategy attribute can_short = False).


text:
Timezone: »

Low-Bit DNN Training with Hardware-Efficient Stochastic Rounding Unit Design
Sung-En Chang · Geng Yuan · Alec Lu · Mengshu Sun · Yanyu Li · Xiaolong Ma · Yanyue Xie · Minghai Qin · Xue Lin · Zhenman Fang · Yanzhi Wang

Sat Jul 23 07:00 AM (PDT) @
Stochastic rounding is crucial in the training of low-bit deep neural networks (DNNs) to achieve high accuracy. Unfortunately, prior studies require a large number of high-precision stochastic rounding units (SRUs) to guarantee the low-bit DNN accuracy, which involves considerable hardware overhead. In this paper, we propose an automated framework to explore hardware-efficient low-bit SRUs (ESRUs) that can still generate high-quality random numbers to guarantee the accuracy of low-bit DNN training. Experimental results using state-of-the-art DNN models demonstrate that, compared to the prior 24-bit SRU with 24-bit pseudo random number generator (PRNG), our 8-bit ESRU~with 3-bit PRNG reduces the SRU resource usage by $9.75\times$ while achieving a higher accuracy.


text:
# Step-by-step Solution

Go!
1
2
3
4
5
6
7
8
9
0
a
b
c
d
f
g
m
n
u
v
w
x
y
z
.
(◻)
+
-
×
◻/◻
/
÷
2

e
π
ln
log
log
lim
d/dx
Dx
|◻|
=
>
<
>=
<=
sin
cos
tan
cot
sec
csc

asin
acos
atan
acot
asec
acsc

sinh
cosh
tanh
coth
sech
csch

asinh
acosh
atanh
acoth
asech
acsch

## Step-by-step explanation

Problem to solve:

$\lim_{x\to1}\left(l\cdot\frac{\ln\left(x\right)}{x-1}\right)$

Learn how to solve limits by direct substitution problems step by step online.

$\lim_{x\to1}\left(\frac{l\ln\left(x\right)}{x-1}\right)$

Learn how to solve limits by direct substitution problems step by step online. Evaluate the limit of l(ln(x)/(x-1) as x approaches 1. Multiplying the fraction by l. Evaluate the limit by replacing all occurrences of x by 1. Simplifying. section:If the limit is undefined, we need to find the left side and right side limits.

$\lim_{x\to1}\left(l\cdot\frac{\ln\left(x\right)}{x-1}\right)$


text:
• 12
• 12
• 9
• 10
• 13

# Memory testing program - tell me what you think!

This topic is 4877 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have recently got a new stick of RAM and have been experiencing some problems (though I came to a conclusion that it has to do with Win98 being unable to use more than 512MB of ram). This sort of inspired me to make a rather simple program that tests the memory... The idea is VERY simple: the program keeps allocating dynamic variables until X mb of ram have been allocated. If an allocation fails, it informs the user. I have just one question I'd like to ask though - when watching a RAM-monitoring program while testing my application, I noticed it always allocates more than it's suppose to do - for instance, when I want it to test 100 MB it uses around 130 MB of memory... can someone explain to me why? I am pretty sure I have calculated the dLoops value correctly...
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <windows.h>

class cChain    //just a random chain class that is 24 bytes big
{
public:
cChain(): prev(0), next(0) {}; //reset pointers
cChain * prev;                 //pointer to previous element
cChain * next;                 //pointer to next element
int a;  //an integer just to fill the space
int b;  //an integer just to fill the space
int c;  //an integer just to fill the space
int d;  //an integer just to fill the space
};

void SetColor(int dwFront, int dwBack); //this sets color of the text (for Failed)

using namespace std;

int main(int argc, char *argv[])
{
unsigned int iRamAmount = 0;  //defines how much ram (mb) will be tested
double dLoops = 0;            //how many loops have to be done
cChain Chain;                 //our Chain of dynamically allocated variables
cChain * Current = &Chain;    //pointer to a current element of the chain
int iFailCount = 0;           //how many times did the test fail?
double x;                     //counter used when allocating memory
double y;                     //counter used when freeing memory
int iCurPercent = 0;          //determines which percent we currently are
bool bFail = 0;               //did something fail?

cout << "Enter amount of RAM to be tested (MB): "; //asks the user
cin >> iRamAmount;                                 //gets the user's answer
cout << endl;

if(iRamAmount <= 0) //if somebody put a value smaller/equal to zero...
{
cout << "ERROR: The value must be greater than zero!" << endl; //call him and idiot
system("PAUSE");	 //wait
return 0;     //and quit
}

dLoops = (double)iRamAmount*1024*1024 / sizeof(cChain);  //calculates how many times the loop has to be done

while (kbhit()) getch();   // Empties buffer

cout << "Size of allocated block: " << sizeof(cChain) << " bytes." << endl;
cout << "Memory will be allcoated " << setiosflags(ios::fixed) << setprecision(0) << dLoops << " times." << endl;

cout << "Press any key to begin" << endl << endl;

getch();

for(x = 0; x < dLoops; x++)
{
Current->next = new cChain;  //dynamically allocate more memory!
if(Current->next != 0)       //if it did not fail
{
Current->next->prev = Current;    //set the previous pointer of the next chain element to current chain element
Current = Current->next;          //set current pointer to the next chain element
}
else                         //if allocation failed...
{
iFailCount++;           //increment fail count
bFail = 1;              //set bFailed
}

if(dLoops/100*iCurPercent <= x+1)      //if we got to the next percent...
{
cout << "\r" << setw(3) << (int)((x+1)/dLoops * 100) << "% ; Fail count: " << setw(5) << iFailCount;
//the above simply displays nicely formatted percentage and fail count
if(bFail)          //if allocation failed
{
SetColor(4,0);
cout << "\tFailed!"; //display a red warning
SetColor(7,0);
}
iCurPercent++;                  //increase the next percent we're looking for
}

if(kbhit())                    //if someone pressed something
{
cout << endl <<"Aborted" << endl;     //say abort
getch();                              //empty the buffer
break;                                //break the loop
}
}

cout << endl << endl << "Freeing memory..." << endl << endl; //inform the user

iCurPercent = 0;  //reset current percent since we're starting again...
bFail = 0;        //reset bFail since we're starting again...

for(y = 0; y < x; y++)   //do this loop as many times as we have allocated memory
{
if(Current->prev != 0)          //if the previous pointer is not 0 (shouldn't be)
{
Current = Current->prev;  //set current pointer to the previous element of chain
delete Current->next;     //delete next element of chain (we're moving back)
}
else                            //if the previous pointer is 0
{
bFail = 1;                 //something went wrong...
}

if(x/100*iCurPercent <= (y+1))   //if we got to the next percent...
{
cout << "\r" << setw(3) << (int)((y+1)/x * 100) << "% ; Fail count: " << setw(5) << iFailCount;
//the above simply displays nicely formatted percentage and fail count
if(bFail)          //if the previous pointer was 0 (shouldn't be)
{
SetColor(4,0);
cout << "\tPrevious pointer is 0"; //inform the user
SetColor(7,0);
}

iCurPercent++;     //increment current percent
}

if(kbhit())                    //if someone pressed something
{
cout << endl <<"Aborted" << endl;     //say abort
getch();                              //empty the buffer
break;                                //break the loop
}
}

cout << endl << endl << "Test finished.\nMemory Tested: " << x/1024/1024 * sizeof(cChain) << " MB.\nFail count: " << iFailCount << endl;
//inform user
system("PAUSE");	 //wait
return 0; // go home!
}

void SetColor(int dwFront, int dwBack)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 16 * dwBack + dwFront);
}

As a side note, how "good" do you think this program is? Certainely it's not the most professional way to test RAM, but if I run it every now and then, getting no errors - do you think it's safe to assume my stick is ok...?

##### Share on other sites
When you allocate a block of memory, the runtime will also allocate additional book keeping information, as well as possibly padding to meet alignment restrictions. This tends to run from 4 to 32 bytes total per allocation on 32 bit systems. This extra memory tends to go inline immediately before the allocated memory block for bookkeeping inforation and immediately afterwards for padding.

Also, the runtime may allocate additional bookkeeping information out of line. If it does so, it usually runs from 8 to 16 bytes in size per allocation, again for 32 bit systems.

On top of that, in debug builds, the runtime may put additional padding on either side of the allocated block to check for buffer overruns.

Also, the runtime generally allocates in chunks from the operating system, when you reach the limit of what it's allocated, it may get another large chunk from the OS, which needs some amount of overhead to manage, and so on.

That's just off the top of my head. On the whole, there are a lot of places that extra memory used can be coming from.

##### Share on other sites
That is really cool. you should make one for video memory if it is possible.

##### Share on other sites
Quote:
 Original post by SiCraneWhen you allocate a block of memory, the runtime will also allocate additional book keeping information, as well as possibly padding to meet alignment restrictions. This tends to run from 4 to 32 bytes total per allocation on 32 bit systems. This extra memory tends to go inline immediately before the allocated memory block for bookkeeping inforation and immediately afterwards for padding.Also, the runtime may allocate additional bookkeeping information out of line. If it does so, it usually runs from 8 to 16 bytes in size per allocation, again for 32 bit systems.On top of that, in debug builds, the runtime may put additional padding on either side of the allocated block to check for buffer overruns.Also, the runtime generally allocates in chunks from the operating system, when you reach the limit of what it's allocated, it may get another large chunk from the OS, which needs some amount of overhead to manage, and so on.That's just off the top of my head. On the whole, there are a lot of places that extra memory used can be coming from.

So essentially... you can't predict how much memory will be exactly allocated...?
Hmm, maybe if, instead of allocating X amount of times, I would keep allocating until I have allocated Y amount of memory... uuh.. so how do you retrieve the different info about RAM state ;) ?

Quote:
 http://www.memtest86.com/

Yes, I know, but I wanted to do something myself just for the heck of it...

Anywas, do you think I should include more tests? For instance, I could set the integers in my cChain: a = 2; b = 3; c = 4; d = a*b*c; and then check if d == 24. Think that would be a good idea...?

##### Share on other sites
Try to allocate large amounts of memory at a time, so you will
avoid great memory waste because of padding:

e.g. you can change the cChain class

#define SIZE 1024 class cChain    { public: cChain(): prev(0), next(0) {}; //reset pointers cChain * prev;                 //pointer to previous element cChain * next;                 //pointer to next element int a[SIZE];  //continuous memory block to fill the space};

The above code will allocate the "a" as a continuous block of
memory, so you will not have many memory leaks because of padding.

You can also try to set "SIZE" to different values and test what happens.

##### Share on other sites
Thanks for the tip Jimmy, certainely a good idea!

##### Share on other sites
This comment is for your own good...

Stop what you are doing! Your program is as good as useless.
Sorry but you don't seem to know the first thing about properly checking RAM so you're only wasting your time.

Your program really is extremely inferrior to proper RAM testing programs. If you really want to know if your RAM is faulty then you must use a proper RAM testing program like: MemTest-86

DOH, someone else beat me to it...

##### Share on other sites
Quote:
 Original post by iMalcThis comment is for your own good...

So why do you think I posted this here...? :)

##### Share on other sites
To test whether the ram is faulty, you need to do a lot more than check whether allocation fails.
It might allocate the memory, and even write data to it, but when you try to read it, it might return a garbled value.

Or it might store the correct data *until* an adjacent cell is written to, which corrupts it. Or only some bits might be corrupted.

Basically, use a "proper" program for it. It gets really messy ,and practically impossible to do reliable under Windows, due to the use of virtual memory and other abstractions.
You really have no guarantee that what you're writing will end up using the entire ram stick when running it under Windows.

If you really want to do this yourself, I'd suggest you google for other mem-testing apps, and read the documentation for those. Some of them are open source, and some have pretty detailed information available on how they tackle the problem. Because it's a lot more complicated than just checking whether an allocation fails. :)


text:
Symmetric inverse semigroup

In abstract algebra, the set of all partial bijections on a set X (a.k.a. one-to-one partial transformations) forms an inverse semigroup, called the symmetric inverse semigroup[1] (actually a monoid) on X. The conventional notation for the symmetric inverse semigroup on a set X is ${\displaystyle {\mathcal {I}}_{X}}$[2] or ${\displaystyle {\mathcal {IS}}_{X}}$[3] In general ${\displaystyle {\mathcal {I}}_{X}}$ is not commutative.

Details about the origin of the symmetric inverse semigroup are available in the discussion on the origins of the inverse semigroup.

Finite symmetric inverse semigroups

When X is a finite set {1, ..., n}, the inverse semigroup of one-one partial transformations is denoted by Cn and its elements are called charts or partial symmetries.[4] The notion of chart generalizes the notion of permutation. A (famous) example of (sets of) charts are the hypomorphic mapping sets from the reconstruction conjecture in graph theory.[5]

The cycle notation of classical, group-based permutations generalizes to symmetric inverse semigroups by the addition of a notion called a path, which (unlike a cycle) ends when it reaches the "undefined" element; the notation thus extended is called path notation.[6]

Notes

1. ^ Pierre A. Grillet (1995). Semigroups: An Introduction to the Structure Theory. CRC Press. p. 228. ISBN 978-0-8247-9662-4.
2. ^ Hollings 2014, p. 252
3. ^ Ganyushkin and Mazorchuk 2008, p. v
4. ^ Lipscomb 1997, p. 1
5. ^ Lipscomb 1997, p. xiii
6. ^ Lipscomb 1997, p. xiii

References

• S. Lipscomb, "Symmetric Inverse Semigroups", AMS Mathematical Surveys and Monographs (1997), ISBN 0-8218-0627-0.
• Olexandr Ganyushkin; Volodymyr Mazorchuk (2008). Classical Finite Transformation Semigroups: An Introduction. Springer Science & Business Media. ISBN 978-1-84800-281-4.
• Christopher Hollings (2014). Mathematics across the Iron Curtain: A History of the Algebraic Theory of Semigroups. American Mathematical Society. ISBN 978-1-4704-1493-1.


text:
Running an unmanged graphics engine in managed code

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am running a directX graphics engine in a WinForm, specifically the Irrlicht engine, running in a picturebox. Everything is working fine, except that I occasionally get the following error:
An unhandled exception of type 'System.AccessViolationException' occurred in myProgram.exe

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
This happens when I try to resize the window, which triggers an event, where I manually resize the engine. This call resets the engine (which is good), but after all of that I get that error. I think this is because it is managed code that shouldn't be (I think). Here is relevant code:
public ref class IrrlichtManager
{
//stuff
void Init();
}

This is my manager class that wraps up the Irrlicht stuff in a managed class (ref). This is how I use it:
irrManager = gcnew IrrManager();

This is my thread. I guess I shouldn't make IrrlichtManager managed, right? But I don't know how to make a thread with an unmanaged class. ThreadStart requires its first parameter to be System::Object^, which can only be managed classes. However, it can be overloaded, although I can't figure it out: the sole parameter when overloaded is described as: ThreadStart(void (*)(void)). What is that? I tried messing around with reinterpret_cast to void* but I couldn't get it to compile. There is no documentation anywhere. Another thing I tried was to make IrrlichtManager unmanaged and make a managed wrapper class for it. This did not help (unsurprisingly). So my theory, as I said earlier, is that Irrlicht is doing it's own thing but is accidentally touching the managed heap (or maybe vice versa). I'm still new with managed C++ so I might be missing some concepts here. Do you know how I can successfully put this unmanged graphics engine into one of my winforms, without these resource access errors? Thanks.

Share on other sites
Just a little question: why are you not using the .NET-wrapper of the IRRLICHT to do this job? Maybe there such problem are already solved.

Kimmi

Share on other sites
Well, I have considered it but I have decided not to for various reasons, such as me already having written a lot of native C++ for this project, and the reduced support for the wrapper.

Share on other sites
Well, I figured out the void thing, but it didn't help.

However, after doing a bit of research there's some native/managed mixing stuff out there, so I'll take a look at that.

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
17
5. 5

• 14
• 30
• 13
• 11
• 11
• Forum Statistics

• Total Topics
631774
• Total Posts
3002295
×


text:
# How to reduce the Confluence footer height

#### Still need help?

The Atlassian Community is here for you.

## Purpose

The Confluence footer does take up a decent amount of room, so you might desire to make it smaller. The Atlassian Customer Agreement requires attribution, but only in the following format:

“Powered by Atlassian,” which must in every case include a hyperlink to http://www.atlassian.com, and which must be in the same format as delivered in the Software.

## Solution

Remove the Atlassian logo, and all spacing around the required text by performing the following steps:

1. Go the Confluence Administration page (via the cog)
2. Go to Custom HTML
3. Click the Edit button
4. Paste the following into the section labelled "

<style>
#footer .footer-body {
margin:0;
min-height:0;
}
#footer-logo {
display: none !important;
}
</style>
5. Click Save and go to any Confluence page to verify the footer is now smaller


text:
# 1.6: Proof

Mathematics is unique in that it claims a certainty that is beyond all pos- sible doubt or argument. A mathematical proof shows how some result follows by logic alone from a given set of assumptions, and once the result has been proven, it is as solid as the foundations of logic themselves. Of course, mathematics achieves this certainty by restricting itself to an arti- ficial, mathematical world, and its application to the real world does not carry the same degree of certainty.

Within the world of mathematics, consequences follow from assumptions with the force of logic, and a proof is just a way of pointing out logical consequences. There is an old mathematical joke about this:

This mathematics professor walks into class one day and says “We’ll start today with this result, which is obvious,” and he writes it on the board. Then, he steps back and looks at the board for a while. He walks around the front of the room, stares into space and back at the board. This goes on till the end of class, and he walks out without saying anything else. The next class period, the professor walks into the room with a big smile, writes the same result on the board, turns to the class and says, “I was right. It is obvious.”

For of course, the fact that mathematical results follow logically does not mean that they are obvious in any normal sense. Proofs are convincing once they are discovered, but finding them is often very difficult. They are written in a language and style that can seem obscure to the uninitiated. Often, a proof builds on a long series of definitions and previous results, and while each step along the way might be “obvious,” the end result can be surprising and powerful. This is what makes the search for proofs worthwhile.

In the rest of this chapter, we’ll look at some approaches and techniques that can be used for proving mathematical results, including two important proof techniques known as proof by contradiction and mathematical induc- tion. Along the way, we’ll encounter a few new definitions and notations. Hopefully, you will be left with a higher level of confidence for exploring

The mathematical world and the real world weren’t always quite so separate. Until some time near the middle of the nineteenth century, the statements of mathematics were regarded as statements about the world. A proof was simply a convincing argument, rather than a chain forged of absolute logic. It was something closer to the original meaning of the word “proof”, as a test or trial: To prove something was to test its truth by putting it to the trial of logical argument.

The first rumble of trouble came in the form of non-Euclidean geometry. For two thousand years, the geometry of the Greek mathematician Euclid had been accepted, simply, as the geometry of the world. In the middle of the nineteenth century, it was discovered that there are other systems of geometry, which are at least as valid and self-consistent as Eu- clid’s system. Mathematicians can work in any of these systems, but they cannot all claim to be working in the real world.

Near the end of the nineteenth century came another shock, in the form of cracks in the very foundation of mathematics. At that time, mathematician Gottlieb Frege was finishing a book on set theory that represented his life’s work. In Frege’s set theory, a set could be defined by any property. You could have, for example, the set consisting of all sets that contain three objects. As he was finishing his book, Frege received a letter from a young mathematician named Bertrand Russell which described what be- came known as Russell’s Paradox. Russell pointed out that the set of all sets—that is, the set that contains every entity that satisfies the property of being a set—cannot logically exist. We’ll see Russell’s reasoning in the following chapter. Frege could only include a postscript in his book stating that the basis of the work had been swept away.

Mathematicians responded to these problems by banishing appeals to facts about the real world from mathematical proof. Mathematics was to be its own world, built on its own secure foundation. The foundation would be a basic set of assumptions or “axioms” from which everything else would follow by logic. It would only be necessary to show that the axioms themselves were logically consistent and complete, and the world of mathematics would be secure. Unfortunately, even this was not to be. In the 1930s, Kurt G ̈odel showed that there is no consistent, finite set of axioms that completely describes even the corner of the mathematical world known as arithmetic. G ̈odel showed that given any finite, consistent set of axioms, there are true statements about arithmetic that do not follow logically from those axioms.

We are left with a mathematical world in which iron chains of logic still bind conclusions to assumptions. But the assumptions are no longer rooted in the real world. Nor is there any finite core of axioms to which the rest of the mathematical world can be chained. In this world, axioms are set up as signposts in a void, and then structures of logic are built around them. For example, instead of talking about the set theory that describes the real world, we have a set theory, based on a given set of axioms. That set theory is necessarily incomplete, and it might differ from other set theories which are based on other sets of axioms.

Understandably, mathematicians are very picky about getting their proofs right. It’s how they construct their world. Students sometimes object that mathematicians are too picky about proving things that are “obvious.” But the fact that something is obvious in the real world counts for very little in the constructed world of mathematics. Too many ob- vious things have turned out to be dead wrong. (For that matter, even things in the real world that seem “obviously” true are not necessarily true at all. For example, consider the quantity $$f(n) = n2 + n + 41$$. When $$n = 0, f(n) = 41$$ which is prime; when $$n = 1, f(n) = 43$$ which is prime; when $$n = 2, f(n) = 47$$, which is prime. By the time you had calculated $$f(3),f(4),...,f(10)$$ and found that they were all prime, you might conclude that it is “obvious” that $$f(n)$$ is prime for all $$n ≥ 0$$. But this is not in fact the case! (See exercises.) Similarly, those of you who are baseball fans might consider it “obvious” that if player A has a higher batting average against left-handers than player $$B$$, and player $$A$$ has a higher batting average against right-handers than player $$B$$, then player $$A$$ must have a higher batting average than player $$B$$. Again, this is not true!)

As we saw in Section 1.5, a formal proof consists of a sequence of statements where each statement is either an assumption or follows by a rule of logic from previous statements. The examples in that section all worked with unspecified generic propositions ($$p, q,$$ etc). Let us now look at how one might use the same techniques to prove a specific proposition about the mathematical world. We will prove that for all integers $$n$$, if $$n$$ is even then $$n^2$$ is even. (Definition: an integer $$n$$ is even iff $$n = 2k$$ for some integer $$k$$. For example, 2 is even since 2 = 2·1; 66 is even since 66 = 2·33; 0 is even since 0 = 2 · 0.)

Proof. This is a proposition of the form $$∀n(P(n) → Q(n))$$ where $$P(n)$$ is “$$n$$ is even” and $$Q(n)$$ is “$$n^2$$ is even.” We need to show that $$P(n) → Q(n)$$ is true for all values of $$n$$. In the language of Section 1.5, we need to show that for any $$n$$, $$P(n)$$ logically implies $$Q(n)$$; or, equivalently, that $$Q(n)$$ can be logically deduced from $$P(n)$$; or, equivalently, that

$$n$$ is even
___________
$$∴ n2 is even$$

is in fact a valid argument for any value of $$n$$:
Let $$n$$ be an arbitrary integer.

 1. $$n$$ is even premise 2. if $$n$$ is even,then $$n=2k$$ for some integer $$k$$ definition of even 3. $$n =2k$$ for some integer$$k) from 1, 2 (modus ponens) 4. if \(n = 2k$$ for some integer $$k$$ the $$n^2 = 4k^2$$ for some integer $$k$$ basic algebra 5. $$n^2 = 4k^2$$ for some integer $$k$$ from 3,4 (modus ponens) 6. if $$n^2 = 4k^2$$ for some integer $$k$$ then $$n^2 = 2(2k^2) for that \(k$$ basic algebra 7. $$n^2 = 2(2k^2) for some integer \(k$$ from 5,6 (modus ponens) 8. if $$n2 = 2(2k2)$$ for some integer $$k$$, then $$n2 = 2k′$$ for some integer $$k′$$ basic fact about integers 9. $$n^2 = 2k'$$ for some integer $$k'$$ from 7,8 (modus ponens) 10. if $$n^2 = 2k'$$ for some integer $$k'$$, then $$n^2$$ is even definition of even 11. $$n^2$$ is even from 9, 10 (modus ponens)

(The “basic fact about integers” referred to above is that the product of integers is again an integer.) Since $$n$$ could be replaced by any integer throughout this argument, we have proved the statement “if $$n$$ is even then $$n^2$$ is even” is true for all integers $$n$$. (You might worry that the argument is only valid for even $$n$$; remind yourself that $$P (n) → Q(n)$$ is automatically true if $$P(n)$$ is false.)

Mathematical proofs are rarely presented with this degree of detail and formality. A slightly less formal proof of our proposition might leave out the explicit implications and instances of modus ponens and appear as follows:

Proof. Let n be an arbitrary integer.

 1. $$n$$ is even premise 2. $$n = 2k$$ for some integer $$k) definition of even 3. \(n^2 = 4k^2$$ for that integer $$k$$ basic algebra 4. $$n^2 = 2(2k^2)$$ for that $$k$$ basic algebra 5. $$n^2 =2k'$$ for some integer $$k'$$ substituting $$k' = 2k^2$$ 6. $$n^2$$ is even definition of even

Since $$n$$ was an arbitrary integer, the statement is true for all integers.

A more typical proof would take the argument above and present it in prose rather than list form:

Proof. Let $$n$$ be an arbitrary integer and assume $$n$$ is even. Then $$n = 2k$$ for some integer $$k$$ by the definition of even, and $$n^2 = 4k^22 = 2(2k^2)$$. Since the product of integers is an integer, we have $$n^2 = 2k′$$ for some integer $$k′$$. Therefore $$n^2$$ is even. Since $$n$$ was an arbitrary integer, the statement is true for all integers.

Typically, in a “formal” proof, it is this kind of (relatively) informal discussion that is given, with enough details to convince the reader that a complete, formal proof could be constructed. Of course, how many details the reader can be expected to fill in depends on the reader, and reading proofs is a skill that must be developed and practiced. Writing a proof is even more difficult. Every proof involves a creative act of discovery, in which a chain of logic that leads from assumptions to conclusion is discovered. It also involves a creative act of expression, in which that logic is presented in a clear and convincing way. There is no algorithm for producing correct, coherent proofs. There are, however, some general guidelines for discovering and writing proofs.

One of the most important pieces of advice to keep in mind is, “Use the definition.” In the world of mathematics, terms mean exactly what they are defined to mean and nothing more. Definitions allow very complex ideas to be summarized as single terms. When you are trying to prove things about those terms, you generally need to “unwind” the definitions. In our example above, we used the definition of even to write $$n = 2k$$, and then we worked with that equation. When you are trying to prove something about equivalence relations in Chapter 2, you can be pretty sure that you will need to use the fact that equivalence relations, by definition, are symmetric, reflexive, and transitive. (And, of course, you’ll need to know how the term “relation” is defined in the first place! You’ll get nowhere if you work from the idea that “relations” are something like your aunt and uncle.)

More advice along the same line is to check whether you are using the assumptions of the theorem. An assumption that is made in a theorem is called an hypothesis. The hypotheses of the theorem state conditions whose truth will guarantee the conclusion of the theorem. To prove the theorem means to assume that the hypotheses are true, and to show, under that assumption, that the conclusion must be true. It’s likely (though not guaranteed) that you will need to use the hypotheses explicitly at some point in the proof, as we did in our example above.$$^12$$ Also, you should keep in mind that any result that has already been proved is available to be used in your proof.

A proof is a logical argument, based on the rules of logic. Since there are really not all that many basic rules of logic, the same patterns keep showing up over and over. Let’s look at some of the patterns.

The most common pattern arises in the attempt to prove that something is true “for all” or “for every” or “for any” entity in a given category. In terms of logic, the statement you are trying to prove is of the form $$∀x P (x)$$. In this case, the most likely way to begin the proof is by saying something like, “Let $$x$$ be an arbitrary entity in the domain of discourse. We want to show that $$P(x)$$.” In the rest of the proof, $$x$$ refers to some unspecified but definite entity in the domain of discourse. Since $$x$$ is arbitrary, proving $$P(x)$$ amounts to proving $$∀xP(x)$$. You only have to be careful that you don’t use any facts about $$x$$ beyond what you have assumed. For example, in our proof above, we cannot make any assumptions about the integer $$n$$ except that it is even; if we had made such assumptions, then the proof would have been incorrect, or at least incomplete.

Sometimes, you have to prove that an entity exists that satisfies certain stated properties. Such a proof is called an existence proof . In this case, you are attempting to prove a statement of the form $$∃x P (x)$$. The way to do this is to find an example, that is, to find a specific entity a for which $$P(a)$$ is true. One way to prove the statement “There is an even prime number” is to find a specific number that satisfies this description. The same statement could also be expressed “Not every prime number is odd.” This statement has the form $$¬(∀x P (x))$$, which is equivalent to the statement $$∃x (¬P (x))$$. An example that proves the statement $$∃x (¬P (x))$$ also proves $$¬(∀x P (x))$$. Such an example is called a counterexample to the statement $$∀xP(x)$$: A counterexample proves that the statement $$∀x P(x)$$ is false. The number 2 is a counterexample to the statement “All prime numbers are odd.” In fact, 2 is the only counterexample to this statement; many statements have multiple counterexamples.

$$^{12}$$Of course, if you set out to discover new theorems on your own, you aren’t given the hypotheses and conclusion in advance, which makes things quite a bit harder—and more interesting.

Note that we have now discussed how to prove and disprove universally quantified statements, and how to prove existentially quantified statements. How do you disprove ∃x $$P (x)$$? Recall that $$¬∃x P (x)$$ is logically equivalent to $$∀x (¬P (x))$$, so to disprove $$∃x P (x)$$ you need to prove $$∀x (¬P (x))$$.

Many statements, like that in our example above, have the logical form of an implication, $$p → q$$. (More accurately, they are of the form “$$∀x (P (x) → Q(x))$$”, but as discussed above the strategy for proving such a statement is to prove $$P(x) → Q(x)$$ for an arbitrary element $$x$$ of the domain of discourse.) The statement might be “For all natural numbers $$n$$, if $$n$$ is even then $$n^2$$ is even,” or “For all strings $$x$$, if $$x$$ is in the language $$L$$ then $$x$$ is generated by the grammar $$G$$,” or “For all elements s, if $$s ∈ A$$ then $$s ∈ B$$.” Sometimes the implication is implicit rather than explicit: for example, “The sum of two rationals is rational” is really short for “For any numbers $$x$$ and $$y$$, if $$x$$ and $$y$$ are rational then $$x + y$$ is rational.” A proof of such a statement often begins something like this: “Assume that $$p$$. We want to show that $$q$$.” In the rest of the proof, $$p$$ is treated as an assumption that is known to be true. As discussed above, the logical reasoning behind this is that you are essentially proving that

$$p$$
____
$$∴q$$

is a valid argument. Another way of thinking about it is to remember that $$p → q$$ is automatically true in the case where $$p$$ is false, so there is no need to handle that case explicitly. In the remaining case, when $$p$$ is true, we can show that $$p → q$$ is true by showing that the truth of $$q$$ follows from the truth of $$p$$.

A statement of the form p ∧ q can be proven by proving p and q sepa- rately. A statement of the form p∨q can be proved by proving the logically equivalent statement (¬p) → q: to prove p ∨ q, you can assume that pis false and prove, under that assumption, that q is true. For example, the statement “Every integer is either even or odd” is equivalent to the statement “Every integer that is not even is odd.”

Since $$p ↔ q$$ is equivalent to $$(p → q)∧(q → p)$$, a statement of the form $$p ↔ q$$ is often proved by giving two proofs, one of $$p → q$$ and one of $$q → p$$. In English, $$p ↔ q$$ can be stated in several forms such as “$$p$$ if and only if $$q$$”, “if $$p$$ then $$q$$ and conversely,” and “$$p$$ is necessary and sufficient for $$q$$.” The phrase “if and only if” is so common in mathematics that it is often abbreviated iff.

You should also keep in mind that you can prove $$p → q$$ by displaying a chain of valid implications $$p→r→s→···→q$$. Similarly, $$p↔q$$ can be proved with a chain of valid biconditionals $$p ↔ r ↔ s ↔ ··· ↔ q$$.

We’ll turn to a few examples, but first here is some terminology that we will use throughout our sample proofs:

• The natural numbers (denoted $$mathbb{N}$$ are the numbers 0, 1, 2, . . .. Note that the sum and product of natural numbers are natural numbers.

• The integers (denoted $$mathbb{Z}$$ are the numbers 0,−1,1,−2,2,−3,3,.... Note that the sum, product, and difference of integers are integers.

• The rational numbers (denoted $$mathbb{Q}$$ are all numbers that can be written in the form $$\frac{m}{n}$$ where $$m$$ and $$n$$ are integers and $$n \ne 0$$. So $$\frac{1}{3}$$ and $$\frac{-65}{7}$$ are rationals; so, less obviously, are 6 and $$\frac{\sqrt{27}}{\sqrt{12}}$$ since 6 = $$\frac{6}{1}$$ (or, for that matter, 6 = $$\frac{-12}{-2}$$), and $$\frac{\sqrt{27}}{\sqrt{12}}$$ = $$\sqrt{\frac{27}{12}}$$ = $$\sqrt{\frac{9}{4}}$$ = $$\frac{3}{2}$$. Note the restriction that the number in the denominator cannot be 0: $$\frac{3}{0}$$ is not a number at all, rational or otherwise; it is an undefined quantity. Note also that the sum, product, difference, and quotient of rational numbers (provided you don't attempt to divide by 0.)

• The real numbers (denoted $$\mathbb{R}$$) are numbers that can be written in decimal form, possibly with an infinite number of digits after the decimal point. Note that the sum, product, difference, and quotient of real numbers are real numbers (provided you don’t attempt to divide by 0.)

• The irrational numbers are real numbers that are not rational, i.e. that cannot be written as a ratio of integers. Such numbers include $$\sqrt{3}$$ (which we will prove is not rational) and $$π$$ (if anyone ever told you that $$π = \frac{22}{7}$$ , they lied— $$\frac{22}{7}$$ is only an approximation of the value of $$π$$).

• An integer $$n$$ is divisible by $$m$$ iff $$n = mk$$ for some integer $$k$$. (This can also be expressed by saying that $$m$$ evenly divides $$n$$.) So for example, $$n$$ is divisible by $$2$$ iff $$n = 2k$$ for some integer $$k$$; $$n$$ is divisible by 3 iff $$n = 3k$$ for some integer $$k$$, and so on. Note that if $$n$$ is $$not$$ divisible by 2, then $$n$$ must be 1 more than s multiple of 2 so $$n = 2k +1$$ for some integer $$k$$. Similarly, if $$n$$ is not divisible by 3 then $$n$$ must be 1 or 2 more than a multiple of 3, so $$n = 2k+1$$ or $$n=2k+2$$ for some integer k.
• An integer is even iff it is divisible by 2 and odd iff it is not.

• An integer n > 1 is prime if it is divisible by exactly two positive integers, namely 1 and itself. Note that a number must be greater than 1 to even have a chance of being termed “prime”. In particular, neither 0 nor 1 is prime.

Let’s look now at another example: prove that the sum of any two rational numbers is rational.

Proof. We start by assuming that x and y are arbitrary rational numbers. Here’s a formal proof that the inference rule

$$x$$ is rational
$$y$$ is rational
_______________
$$∴ x+y$$ is rational

is a valid rule of inference:

 1. $$x$$ is rational premise 2. if $$x$$ is rational, then x = $$\frac{a}{b}$$ for some integers $$a$$ and $$b \ne 0$$ definiton of rationals 3. $$x = \frac{a}{b}$$ for some integers $$a$$ and $$b \ne 0$$ from 1,2 (modus ponens) 4. $$y$$ is rational premise 5. if $$y$$ is rational, then y = $$\frac = {c}{d}$$ for some integers $$c$$ and $$d \ne$$ definition of rational 6. $$y = \frac{c}{d}$$ for some $$c$$ and $$d \ne 0$$ from 4,5 (modus ponens) 7. $$x = \frac{a}{b}$$ for some $$a$$ and $$b \ne 0$$ and $$y = \frac{c}{d}$$ for $$c$$ and $$d \ne 0$$ from 3,6 8. if $$x = \frac{a}{b} for some \(a$$ and $$b \ne 0$$ and $$y = \frac{c}{d}$$ for $$c$$ and $$d \ne 0$$then $$x +y = \frac{ad+bc}{bd}$$ where $$a, b, c, d$$ are integers and $$b, d \neg 0$$ basic algebra 9. $$x +y = \frac{ad+bc}{bd}$$ for some $$a, b, c, d$$ where $$b,d \neg 0$$ from 7,8 (modus ponens) 10. if $$x + y = \frac{ad +bc}{bd}$$ for some $$a,b,c,d$$ where $$b,d \ne 0$$ then $$x+y = \frac{m}{n} where \(m,n$$ are integers and $$n \ne 0$$ properties of integers 11. $$x +y = \frac{m}{n}$$ where $$m$$ and $$n$$ are integers and $$n \ne 0$$ from 9,10 (modus ponens) 12. if $$x +y = \frac{m}{n}$$ where $$m$$ and $$n$$ are integers and $$n \ne 0$$ then $$x + y$$ is rational definition of rational 13. $$x+y$$ is rational from 11,12 (modus ponens)

So the rule of inference given above is valid. Since $$x$$ and $$y$$ are arbitrary rationals, we have proved that the rule is valid for all rationals, and hence the sum of any two rationals is rational.

Proof. Let x and y be arbitrary rational numbers. By the definition of rational, there are integers $$a,b \ne 0$$, $$c,d \ne 0$$ such that $$x = \frac{a}{b}$$ and $$y = \frac{c}{d}$$. Then $$x+y = \frac{ad+bc}{bd}$$ ; we know $$ad+bc$$ and $$bd$$ are integers since the sum and product of integers are integers, and we also know $$bd \ne 0$$ since neither $$b$$ nor $$d$$ is 0. So we have written $$x+y$$ as the ratio of two integers, the denominator being non-zero. Therefore, by the definition of rational numbers, $$x + y$$ is rational. Since $$x$$ and $$y$$ were arbitrary rationals, the sum of any two rationals is rational.

And one more example: we will prove that any 4-digit number $$d_{1} d_{2} d_{3} d_{4}$$ is divisible by 3 iff the sum of the four digits is divisible by 3.

Proof. This statement is of the form $$p ↔ q$$; recall that $$p ↔ q$$ is logically equivalent to $$(p → q) ∧ (q → p)$$. So we need to prove for any 4-digit number $$d_{1} d_{2} d_{3} d_{4}$$ that (1) if $$d_{1} d_{2} d_{3} d_{4}$$ is divisible by 3 then $$d_{1} +d_{2} +d_{3} +d_4$$ is divisible by 3, and (2) if $$d_{1} +d_{2} +d_{3} +d_4$$ is divisible by 3 then $$d_{1} d_{2} d_{3} d_{4}$$ is divisible by 3. So let $$d_{1} d_{2} d_{3} d_{4}$$ be an arbitrary 4-digit number.

(1) Assume $$d_{1} d_{2} d_{3} d_{4}$$ is divisible by 3, i.e. $$d_{1} d_{2} d_{3} d_{4}$$ = 3k for some integer k. The number $$d_{1} d_{2} d_{3} d_{4}$$ is actually $$d_{1}×1000+d_{2}×100+d_{3}×10+d_{4}$$, so we have the equation

$d_{1} ×1000+d_{2} ×100+d_{3} ×10+d_{4} =3k.$

Since 1000 = 999+1, 100 = 99+1, and 10 = 9+1, this equation can be rewritten

$999d_{1} +d_{1} +99d_{2} +d_{2} +9d_{3} +d_{3} +d_{4} =3k.$

Rearranging gives

$d_{1} +d_{2} +d_{3} +d_{4} =3k−999d_{1} −99d_{2} −9d_{3} = 3k − 3(333d_{1}) − 3(33d_{2}) − 3(3d_{3})$

We can now factor a 3 from the right side to get

$d1 +d2 +d3 +d4 =3(k−333d_{1} −33d_{2} −d_{3}).$

Since (k−333d_{1}−33d_{2}−d_{3}) is an integer, we have shown that $$d_{1}+d_{2}+d_{3}+d_{4}$$ is divisible by 3.

(2) Assume $$d_{1} + d_{2} + d_{3} + d_{4} is divisible by 3. Consider the number \(d_{1} d_{2} d_{3} d_{4}$$. As remarked above,

$$$d_{1} d_{2} d_{3} d_{4}$$ = d_{1} ×1000+d_{2} ×100+d_{3} ×10+d_{4}\)$

so

$d_{1}d_{2}d_{3}d_{4} = 999d_{1} +d_{1} +99d_{2} +d_{2} +9d_{3} +d_{3} +d_{4} = 999d_{1} +99d_{2} +9d_{3} +(d_{1} +d_{2} +d_{3} +d_{4})$

We assumed that $$d_{1} +d_{2} +d_{3} +d_{4} =3k$$ for some integer $$k$$, so we can substitute into the last equation to get

$d_{1} d_{2} d_{3} d_{4} = 9999d_{1}+99d_{2} +9d_{3} +3k=3(333d_{1} +33d_{2} +3d_{3} +k).$

Since the quantity in parentheses is an integer, we have proved that $$d_{1}d_{2}d_{3}d_{4}$$ is divisible by 3.

In (1) and (2) above, the number $$d_{1}d_{2}d_{3}d_{4}$$ was an arbitrary 4-digit integer, so we have proved that for all 4-digit integers, $$d_{1}d_{2}d_{3}d_{4}$$ is divisible by 3 iff the sum of the four digits is divisible by 3.

Now suppose we wanted to prove the statement “For all integers $$n$$, $$n^2$$ is even if and only if $$n$$ is even.” We have already proved half of this statement (“For all integers $$n$$, if $$n$$ is even then $$n^2$$ is even”), so all we need to do is prove the statement “For all integers $$n$$, if $$n^2$$ is even then $$n$$ is even” and we’ll be done. Unfortunately, this is not as straightforward as it seems: suppose we started in our standard manner and let $$n$$ be an arbitrary integer and assumed that $$n^2 = 2k$$ for some integer $$k$$. Then we’d be stuck! Taking the square root of both sides would give us n on the left but would leave a $$\sqrt{2k}$$ on the right. This quantity is not of the form $$2k′$$ for any integer $$k′$$; multiplying it by $$\frac{\sqrt{2}}{\sqrt{2}}$$ would give $$2\frac{\sqrt{k}}{\sqrt{2}}$$ but there is no way for us to prove that $$\frac{\sqrt{k}}{\sqrt{2}}$$ is an integer. So we've hit a dead end. What do we do now?

The answer is that we need a different proof technique. The proofs we have written so far are what are called direct proofs: to prove $$p → q$$ you assume $$p$$ is true and prove that the truth of $$q$$ follows. Sometimes, when a direct proof of $$p → q$$ fails, an indirect proof will work. Recall that the contrapositive of the implication $$p → q$$ is the implication $$¬q → ¬p$$, and that this proposition is logically equivalent to $$p → q$$. An indirect proof of $$p → q$$, then, is a direct proof of the contrapositive $$¬q → ¬p$$. In our current example, instead of proving “if $$n^2$$ is even then $$n$$ is even” directly, we can prove its contrapositive “if $$n$$ is not even (i.e. n is odd) then $$n^2$$ is not even (i.e. $$n^2$$ is odd.)” The proof of this contrapositive is a routine direct argument which we leave to the exercises.

### Exercises

1. Find a natural number $$n$$ for which $$n^2 + n + 41$$ is not prime.

2. Show that the propositions $$p ∨ q$$ and $$(¬p) → q$$ are logically equivalent.

3. Show that the proposition $$(p∨q) → r$$ is equivalent to $$(p → r)∧(q → r)$$.

4. Determine whether each of the following statements is true. If it true, prove it. If it is false, give a counterexample.

a) Every prime number is odd
b) Every prime number greater than 2 is odd
c) If $$x$$ and $$y$$ are integers with $$x < y$$, then there is an integer $$z$$ such that $$x < z < y$$.
d) If $$x$$ and $$y$$ are real numbers with $$x < y$$, then there is a real number $$z$$ such that $$x < z < y$$.

5. Suppose that $$r, s$$, and $$t$$ are integers, such that $$r$$ evenly divides $$s$$ and $$s$$ evenly divides $$t$$. Prove that $$r$$ evenly divides $$t$$.

6. Prove that for all integers $$n$$, if $$n$$ is odd then $$n^2$$ is odd.

7. Prove that an integer $$n$$ is divisible by 3 iff $$n^2$$ is divisible by 3. (Hint: give an indirect proof of “if $$n^2$$ is divisible by 3 then $$n$$ is divisible by 3.”)

8. Prove or disprove each of the following statements.
a) The product of two even integers is even.
b) The product of two integers is even only if both integers are even.
c) The product of two rational numbers is rational.
d) The product of two irrational numbers is irrational.
e) For all integers $$n$$, if $$n$$ is divisible by 4 then $$n^2$$ is divisible by 4.
f) For all integers $$n$$, if $$n^2$$ is divisible by 4 then $$n$$ is divisible by 4.


text:
a, B are the roots of the equation ...
Question

a, B are the roots of the equation K (x2 - x) + x + 5 = 0. If K, & K, are the two values of K for which the roots a, B are connected by the relation (WB) + (Bla) = 4/5. Find the value of (K,/K,) + (K,/K,). 1

JEE/Engineering Exams
Maths
Solution
109
4.0 (1 ratings)
( 8+3 ) ( 1<^{2}-161<+1=0 ) ( k ) 3) ry