Forum archive 2000-2006

ymarkov - How to do a variable called "p"

ymarkov - How to do a variable called "p"

by Arnold Pizer -
Number of replies: 0
inactiveTopicHow to do a variable called "p" topic started 2/6/2002; 5:17:39 PM
last post 2/7/2002; 11:08:39 AM
userymarkov - How to do a variable called "p"  blueArrow
2/6/2002; 5:17:39 PM (reads: 1328, responses: 7)
Hello, this Yavor Markov from Rutgers writing.

I have finally started encoding a few simple problems for Business Calc (marginal analysis) to complement the database that is in place. In some of the problems is rather important the variable to be named p (for price obviously). However, there seems to be a problem, because "p" is a perl comand, or at least a ".pg" command. Is there any quick way around that?

Thank you for your help.

<| Post or View Comments |>


userMichael Gage - Re: How to do a variable called  blueArrow
2/6/2002; 7:06:55 PM (reads: 1533, responses: 0)
Hi Yavor,

Can you give an example of the problem you are trying to write? I'll see what I can do to answer your question.

(You can just put the problem text between "<pre> tags so that it prints more or less correctly in a web page:)

<pre>



The problem you are writing goes here:
DOCUMENT();
$p = random(1,3,0.1);



etc.
BEGIN_TEXT
Stuff that is printed out
END_TEXT
ANS(str_cmp($foo));
ENDDOCUMENT();
</pre>

-- Mike

<| Post or View Comments |>


userymarkov - Re: How to do a variable called  blueArrow
2/7/2002; 9:52:48 AM (reads: 1462, responses: 0)
The problem is attached below. It creates the problem set fine, then it displays it well. When I try to evaluate (submit answers) is where the problem comes. It does not like the "p" being part of the answer.
  Body of the problem 
##DESCRIPTION
##KEYWORDS('derivatives')
## Derivatives and the basic functions of economics
##ENDDESCRIPTION

DOCUMENT(); # This should be the first executable line in the problem.



loadMacros(
PG.pl,
PGbasicmacros.pl,
PGchoicemacros.pl,
PGanswermacros.pl,
PGauxiliaryFunctions.pl
);

TEXT(&beginproblem);
$showPartialCorrectAnswers = 1;



$a1 = random(0.04,0.05,0.001);
$b1 = random(700,800,5);
$p1 = random(320,420,5);
$ep1 = $p1/($b1-$p1);
$funct1 = "(-1/$a1)*\p+$b1/$a1";
$funct2 = "\p/($b1-\p)";

TEXT(EV2(<<EOT));
The demand equation for a certain commodity is given by the equation
( p = $b1 - $a1 x ), where ( p ) denotes the unit price (in dollars) and
( x ) denotes the quantity demanded.



Express the quantity demanded as a function ( f(p) ) of the price,
i.e solve for ( x ).
$BR $BR {ans_rule(48) }
$BR
EOT



$ans = $funct1;
&ANS(function_cmp($ans));



TEXT(EV2(<<EOT));
Find the Elasticity of demand function ( E(p) ).
$BR $BR {ans_rule(48) }
$BR
EOT

$ans = $funct2;
&ANS(function_cmp($ans));



TEXT(EV2(<<EOT));
Find The elasticity of demand when the price ( p=$p1 ).

$BR $BR {ans_rule(24) }
$BR
EOT

$ans = $ep1;
&ANS(std_num_cmp($ans));



ENDDOCUMENT(); # This should be the last executable line in the problem.

<| Post or View Comments |>


userymarkov - Re: How to do a variable called  blueArrow
2/7/2002; 9:53:22 AM (reads: 1551, responses: 0)
The problem is attached below. It creates the problem set fine, then it displays it well. When I try to evaluate (submit answers) is where the problem comes. It does not like the "p" being part of the answer.

Body of the problem ##DESCRIPTION ##KEYWORDS('derivatives') ## Derivatives and the basic functions of economics ##ENDDESCRIPTION DOCUMENT(); # This should be the first executable line in the problem.

loadMacros( PG.pl, PGbasicmacros.pl, PGchoicemacros.pl, PGanswermacros.pl, PGauxiliaryFunctions.pl ); TEXT(&beginproblem); $showPartialCorrectAnswers = 1;

$a1 = random(0.04,0.05,0.001); $b1 = random(700,800,5); $p1 = random(320,420,5); $ep1 = $p1/($b1-$p1); $funct1 = "(-1/$a1)*\p+$b1/$a1"; $funct2 = "\p/($b1-\p)"; TEXT(EV2(<<EOT)); The demand equation for a certain commodity is given by the equation ( p = $b1 - $a1 x ), where ( p ) denotes the unit price (in dollars) and ( x ) denotes the quantity demanded.

Express the quantity demanded as a function ( f(p) ) of the price, i.e solve for ( x ). $BR $BR {ans_rule(48) } $BR EOT

$ans = $funct1; &ANS(function_cmp($ans));

TEXT(EV2(<<EOT)); Find the Elasticity of demand function ( E(p) ). $BR $BR {ans_rule(48) } $BR EOT $ans = $funct2; &ANS(function_cmp($ans));

TEXT(EV2(<<EOT)); Find The elasticity of demand when the price ( p=$p1 ). $BR $BR {ans_rule(24) } $BR EOT $ans = $ep1; &ANS(std_num_cmp($ans));

ENDDOCUMENT(); # This should be the last executable line in the problem.

<| Post or View Comments |>


userMichael Gage - Re: How to do a variable called  blueArrow
2/7/2002; 10:18:21 AM (reads: 1520, responses: 0)
Hi,

You need to specify that the independent variable is 'p' (as opposed to 'x' which is the default).

I suggest that you use a slightly newer version of function_cmp called fun_cmp with the following syntax:

 

$ans = "p/($b1-p)";
ANS(fun_cmp($ans, var=>['p']) );



Clicking on the link fun_cmp will give you more information about this answer evaluator and the various options

--Mike

<| Post or View Comments |>


userymarkov - Re: How to do a variable called  blueArrow
2/7/2002; 11:08:39 AM (reads: 1507, responses: 0)
THANK YOU. Your suggestions worked fine.

Yavor

<| Post or View Comments |>