PREP 2015 Question Authoring - Archived

Lost entire problem contents after importing image?

Lost entire problem contents after importing image?

by tim Payer -
Number of replies: 16
Hello,  Can you please tell me where I have made an error in this problem?

I tried to import an image to a problem but had two mishaps.

1.)  I have lost the contents of a problem through hitting the "save" button (instead of the "save as" button) while importing an image.

2.) When I retrieved the problem from the sub-directory created in the procedure for loading an image, I could not run the problem without the following warning error and the image would not render.

  • Errors parsing PGML:
  • Error evaluating command: Unrecognized character \xE2; marked by <-- HERE after n;
  • image(<-- HERE near column 22.
Any help is most appreciated...

# Webwork Workshop 2015  for Payer, Homework 1, Practice:
# Exercises for Survival and Renewal applications: pg460, #34

 
DOCUMENT();
loadMacros("PGstandard.pl",
           "MathObjects.pl",
  "PGML.pl");

Context("Numeric")->flags->set(
tolerance => 1.0,
tolType => 'absolute',
);
Context()->variables->add(t=>"Real");
$po = Real(random(1000, 9000,1000));
$R =Real(random(8, 40,1));
$T =Real(random(5, 14,1));
$ex =Real(random(0.01, 0.15,0.01));
$a =Real(random(5, 14,1));
$c =Real(random(5, 14,1));
$cb =Real(random(5, 14,1));
$g =Formula("($a/($cb))");
#$g1 =Compute("($cbr-1)");
$g1 =Formula("exp(-$ex*$T)*($po+($R/$ex)*(exp($ex*$T)-1))");
$g2 =floor($g1);


TEXT(beginproblem());
BEGIN_PGML
>> [@ image(“file.png”, width=>727, height=>620, tex_size=>500) @]* Male White-legged Damselfly in difficulties at Farndon 5.6.07. Photo © Bryan Roberts 2007. <<  

During the summer months a dragonfly population at the Musky marsh follows a survival and renewal equation with an initial population of [`P_0 = [$po]`] dragonflies, a renewal rate of [`R = [$R]`] , and a survival function of [``S(t) = e^{-[$ex] t}``] at time [`t`] in weeks. Find the population of dragonflies at [`T = [$T]`] weeks.  
*Note!*  Round your decimal answer down to the number of complete dragonflies.

 
 [______________________]{$g2}  



END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*

To find the average number of bacteria over the first [`[$c]`] minutes we must integrate the function multiplied by the reciprocal of the limits of integration.  
[``\begin{aligned}&\\  
Average &= \frac{1}{[$c] - 0}\int_{0}^{[$c]}[$a] e^{[$b] t} dt\\  
Average &= \frac{[$a]}{[$c]}\int_{0}^{[$c]} e^{[$b] t} dt && \text{ Pull the constant.}\\
Average &= \frac{[$a]}{[$c]}\frac{e^{[$b] t}}{([$b] t)'} \Big|_0^[$c] && \text{ Integrate the exponential.}\\
Average &= \frac{[$a]}{[$c]\times[$b]}\left(e^{[$c]\times[$b]} -e^{0\times[$b]}\right) && \text{Pull constants and Evaluate.}\\
Average &= \frac{[$a]}{[$cb]}\left(e^{[$cb]} -1\right) && \text{Reduce.}\\
Average &= [$g]\left(e^{[$cb]} -1\right) && \text{Reduce.}\\
Average &= [$g2] && \text{The average number of bacteria over the first } [$c] \text{ minutes.}
\end{aligned}``]
END_PGML_SOLUTION

ENDDOCUMENT();
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by Gavin LaRose -
Hi Tim,

It looks as if you have your problem file now, but I'm not seeing the image. The error message "Error evaluating command: Unrecognized character \xE2;" stems from having a smart double quote in the image call: “ instead of ". Blech. I changed the smart quotes to the dumb quote and it loads fine.

That said, it looks as if the image file "file.png" doesn't exist in the directory, which means that the problem loads with an error and broken image.

Does that help?
Gavin

In reply to Gavin LaRose

Re: Lost entire problem contents after importing image?

by tim Payer -
Hi Gavin,

Augh!  The smart vs dumb quote problem which i know but forgot.

Unfortunately i am still having problems in that I cant rename the file within the file manager.

I wanted to start over to see if I could start fresh with the process.
Here is what i attempted:

1.) I deleted the reference to the image within the *.pg file.
2.) I renamed the *.pg file.
Renamed it as:  Hoffman_H21_2.pg

3.) I deleted the old directory holding the *.png image file and the old *.pg file.
4.) I refreshed the File manager.
5.)  I created new folder with the same name:

Hoffman_21_2

6.) I refreshed the File manager.

7.) I attempt to rename the new updated *.pg file in an attempt to create a new folder called:

Hoffman_21_2/Hoffman_21_2.pg


But I consistently get this error message:

Can't rename file: No such file or directory

Can you see my glitch?
Thanks.
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by Davide Cervone -
In step 5 when you create the new directory, the File Manger will move to that directory automatically. Did you go back up to the parent directory? I assume so, otherwise you would not be able to select the pg file to rename it.

Is this in the PREP2015 course? I don't seem to see the directory anywhere. If it is, can you tell me where your Hoffman_21_2.pg file currently lives?
In reply to Davide Cervone

Re: Lost entire problem contents after importing image?

by tim Payer -
Hi Davide,

The directory was a little hidden:

local/Payer-Homework1/Hoffman_21_2



Thanks, Tim
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by Davide Cervone -
OK, I found them. The folder is named Hoffman_H21_2, not Hoffman_21_2. The missing "H" may be the problem. You need to me sure that the directory name and the problem name are the same (other than the ".pg" at the end).
In reply to Davide Cervone

Re: Lost entire problem contents after importing image?

by tim Payer -
Hi Davide,

Thank you, and I did miss that change of file name. So I have renamed the file and repeated the process and still to no avail. I can not figure how to place an image in a homework problem! I have followed the the 5 minute sequence of steps that Paul had laid out. I have made a pdf that walks through the process step by step which I have attached to this message.

I am suspecting that the problem is that i am not clear on webwork's filing system? 

Could it be that when I rename the *.pg file to move it into a folder of the same name, the fact that my Homework directory is on the main page of 2015_PREP course away from others that this is too big a jump for the process to work?

File path:
templates/local/Payer-Homework1/Hoffman_H21_1/Hoffman_H21_1.pg

When i return to the file to try open problem #28 in Payer-Homework1 I get this message.

WeBWorK::Utils::readFile(/opt/webwork/courses/2015_PREP_Problem_Authoring/templates/local/Payer-Homework1/Hoffman_H21_2.pg) says: failed to read file /opt/webwork/courses/2015_PREP_Problem_Authoring/templates/local/Payer-Homework1/Hoffman_H21_2.pg: No such file or directory at /opt/webwork/webwork2/lib/WeBWorK/Utils.pm line 166.

I have attached the error statement below.
The code below that, and if it helps the sequence of steps that i am using in a pdf attachment.  Thank you for any help here...

PG question failed to render

Unable to obtain error messages from within the PG question.

WeBWorK Warnings

WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information.

Warning messages

  • Processing of this PG problem was not completed. Probably because of a syntax error.
  • The translator died prematurely and no PG warning messages were transmitted. at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 932.

Request information

TimeTue Jun 30 10:14:51 2015
MethodGET
URI/webwork2/2015_PREP_Problem_Authoring/Payer-Homework1/28/

# Webwork Workshop 2015  for Payer, Homework 1, Practice:
# Exercises for Survival and Renewal applications: pg460, #34


DOCUMENT();
loadMacros("PGstandard.pl",
           "MathObjects.pl",
	   "PGML.pl");

Context("Numeric")->flags->set(
tolerance => 1.0,
tolType => 'absolute',
);
Context()->variables->add(t=>"Real");
$po = Real(random(1000, 9000,1000));
$R =Real(random(8, 40,1));
$T =Real(random(5, 14,1));
$ex =Real(random(0.01, 0.15,0.01));
$a =Real(random(5, 14,1));
$c =Real(random(5, 14,1));
$cb =Real(random(5, 14,1));
$g =Formula("($a/($cb))");
#$g1 =Compute("($cbr-1)");
$g1 =Formula("exp(-$ex*$T)*($po+($R/$ex)*(exp($ex*$T)-1))");
$g2 =floor($g1);


TEXT(beginproblem());
BEGIN_PGML
>> [@ image("Dragonfly_BryonRoberts.png", width=>727, height=>620, tex_size=>500) @]* Bryon_Roberts_Copy_Right_2007.<<
During the summer months a dragonfly population at the Musky marsh follows a survival and renewal equation with an initial population of [`P_0 = [$po]`] dragonflies, a renewal rate of [`R = [$R]`] , and a survival function of [``S(t) = e^{-[$ex] t}``] at time [`t`] in weeks. Find the population of dragonflies at [`T = [$T]`] weeks.
*Note!*  Round your decimal answer down to the number of complete dragonflies.


 [______________________]{$g2}



END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*

To find the average number of bacteria over the first [`[$c]`] minutes we must integrate the function multiplied by the reciprocal of the limits of integration.
[``\begin{aligned}&\\
Average &= \frac{1}{[$c] - 0}\int_{0}^{[$c]}[$a] e^{[$b] t} dt\\
Average &= \frac{[$a]}{[$c]}\int_{0}^{[$c]} e^{[$b] t} dt && \text{ Pull the constant.}\\
Average &= \frac{[$a]}{[$c]}\frac{e^{[$b] t}}{([$b] t)'} \Big|_0^[$c] && \text{ Integrate the exponential.}\\
Average &= \frac{[$a]}{[$c]\times[$b]}\left(e^{[$c]\times[$b]} -e^{0\times[$b]}\right) && \text{Pull constants and Evaluate.}\\
Average &= \frac{[$a]}{[$cb]}\left(e^{[$cb]} -1\right) && \text{Reduce.}\\
Average &= [$g]\left(e^{[$cb]} -1\right) && \text{Reduce.}\\
Average &= [$g2] && \text{The average number of bacteria over the first } [$c] \text{ minutes.}
\end{aligned}``]
END_PGML_SOLUTION

ENDDOCUMENT();
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by Davide Cervone -
It looks like you have successfully created the directory, and moved a copy of the .pg file and the .png file there. I ran the problem from that directory in the Library Browser, and it loads fine.

The error message you give above suggests that you added the problem to a homework set before you used the File Manager to move the .pg file into the sub-directory, so that homework set still points to the file in its original location.

Your homework set seems to include two copies of the problem (problems 27 and 28 point point to the original location of the file). All the other files in that homework set don't seem to be available. I have changed the location of problem 28 to point to the new location, so you should be able to view the problem with its image using problem 28 from your homework set. Problem 27 still points to the old location. But there is a copy of the .pg file there as well. If I were you, I'd remove that one and only keep the one in the sub-directory. Otherwise, you are likely to edit the wrong one and be confused about why the changes aren't showing up when you view it.

So from what I can see, you have everything in place and working, it was just the homework set that had the wrong file name in it, which I have fixed for problem 28.

Davide
In reply to Davide Cervone

Re: Lost entire problem contents after importing image?

by tim Payer -
Thank you Davide!

It looks great, but I need to repeat the process myself.

I am going to try the process of loading an image with a fresh problem just to assure myself that I can manage the steps from A to Z.
Hopefully I do not make any mistakes this time.

Tim


In reply to tim Payer

Re: Lost entire problem contents after importing image?

by tim Payer -
Hello,

I am sorry to report that i am still getting the same error in regards to importing an image into a homework problem. This problem #29  from the directory of Payer-Homework1 on the main page of the PREP_2015 course.
I have placed the code below my messages, but i had to retrieve this code from the directory created to receive the image.

Warning -- there may be something wrong with this question. Please inform your instructor including the warning messages below.

Edit tags:All SubjectsAll ChaptersAll SectionsLevel123456Save

WeBWorK::Utils::readFile(/opt/webwork/courses/2015_PREP_Problem_Authoring/templates/local/Payer-Homework1/Hoffman_H19_65b.pg) says: failed to read file /opt/webwork/courses/2015_PREP_Problem_Authoring/templates/local/Payer-Homework1/Hoffman_H19_65b.pg: No such file or directory at /opt/webwork/webwork2/lib/WeBWorK/Utils.pm line 166.

Could the answer possibly be that I tried to move my file to of Payer-Homework1 to another directory called Payer_HW_Files ?
And so there are now two instances of said directory?

Does the *.pg file need to be moved via the library browser back to its original directory after an image is loaded? the problem works fine as long as I don't place an image in it. After loading an image my *.pg file no longer has the original code and the problem set is empty of code.

There is this message below:
The file '[TMPL]/local/Payer-Homework1/Hoffman_H19_65b.pg' cannot be found.

Clearly i am missing a key point and I am merely repeating the same error. Any help you can give is most appreciated.


# Webwork Workshop 2015  for Payer, Homework 1, Problem 2:
# Given the coordinates for the critical point of a general function the student
# should be able to determine the constants of the parameters for the
# function. Then evaluate the function for a specified input.


DOCUMENT();
loadMacros("PGstandard.pl",
           "MathObjects.pl",
	   "PGML.pl");
loadMacros("contextFraction.pl");

Context("Numeric");
Context("Fraction");
$m = list_random(3,6,10,12,15,20,30);
$d = Real(random(2,10,1));
$t1 = Real(random(1,3,1));
$h = 60;
($mr,$hr) = reduce($m,$h);
$frac =Compute("$m/$h");
$k1 = Compute("$h/$m");
$a = Compute("$k1*$d");
$a1 = Compute("$k1*$d*e");
$at = Compute("$a*$t1");
$kt = Compute("$k1*$t1");
$kt1 = Compute("1-$kt");
$ktn = Compute("$kt-1");
$ans2 = Compute("$at/(e**($ktn))");
Context()->variables->add(A=>"Real");
Context()->variables->add(k=>"Real");
Context()->variables->add(t=>"Real");

TEXT(beginproblem());
BEGIN_PGML
>> [@ image("Intravenous.png", width=>694, height=>657, tex_size=>400) @]* An intravenous drug injection.<<
The concentration of a particular drug within the bloodstream can be determined by the function: [``C(t) = Ate^{-kt}``], where t is the number of hours since the drug was ingested orally and [`C(t)`] is the concentration of the drug in micrograms per ml of blood. Given that [`A`] and [`k`] are both positive constants.

1.  Given that the maximum concentration of [$d] occurs [$m] minutes after ingesting the drug, find the value of [`A`] and [`k`].

    [`k`] = [_____]{("60/[$m]")}
    [`A`] = [_____]{("60*[$d]*e/[$m]")}

2.  What is concentration of the drug in the bloodstream [$t1] hours after its ingestion?

    [`C([$t1])`] = [________]{Compute("(60*[$d]*[$t1]*e**{1-60*[$t1]/[$m]})/[$m]")}

END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*

1.  The maximum concentration of the drug will occur at a critical point because the drug must increase from zero at ingestion and reach a peak value and then gradually dissipate as the body breaks it down. Then the given information yields
two equations both of which can be used to solve for [`k`] and [`A`]. The two equations
are: [`C(\text{c.p.}) = [$d]`], and [`C'(\text{c.p.}) = 0`], where c.p. = critical point. Recognize that the
time in minutes at the maximum concentration must be converted into hours: So t = [$m] minutes = [``\frac{[$m]}{60} = [$frac]``] hours. Then we will use
C[``\left([$frac]\right) = [$d]``] and [``C'\left([$frac]\right) = 0``] to solve for the
constants of [`k`] and [`A`].

    *  First apply the prime tics for the product rule and chain rule.
[``C'(t) = A(t'e^{-kt} + t(e^{-kt})'(-kt)')``]
    *  Take the derivative.
[``C'(t) = A(e^{-kt} -kte^{-kt})``]
    *  Pull the common factor of [``e^{-kt}``] and reduce.
[``C'(t) = Ae^{-kt}(1 -kt)``]
    *  Input [`t = [$frac]`] into the derivative and set to zero to solve for [`k`].
[``C'\left([$frac]\right) = Ae^{-[$frac]k}(1 -[$frac]k) = 0``]
    *  Recognize that [`A`] and [``e^{-[$frac]k}``] can not be zero as both are positive.
[``\begin{aligned}
1 -[$frac]k &= 0 \\
    [$frac]k &= 1 \\
              k &= \frac{1}{[$frac]}\\
              k &=[$k1]
\end{aligned}``]
    *  We can now substitute [`k = [$k1]`] into the general equation of [``C(t) = Ate^{-kt}``] and use [``C\left([$frac]\right) = [$d]``] to solve for [`A`].
[``\begin{aligned}
 C\left([$frac]\right) &= A([$frac])e^{-3\left([$frac]\right)} = [$d]\\
     A([$frac])e^{-1} &= [$d]\\
     \frac{A}{[$k1]e} &= [$d]\\
                          A &= [$a]e \\
                          A &= [$a1]
\end{aligned}``]
    *  Substituting both [`k = [$k1]`] and [`A = [$a]e`] values into the general equation yields the specific equation for the blood concentration:
[``\begin{aligned}
C(t) &= Ate^{-kt}\\
&= [$a]ete^{-[$k1]t}
\end{aligned}``]

    * Combine the common base of e using the rule of exponents to reduce:
[``C(t) = [$a]te^{1-[$k1]t}``]

2.  Evaluate [``C(t)``] at [``t = [$t1]``] hours to determine the concentration of the drug in the blood stream. We use the reduced form:
[``\begin{aligned} &\\
C([$t1]) &= [$a]([$t1])e^{1-[$k1]([$t1])}\\
& = [$at]e^{1-[$kt]}\\
& = [$at]e^{[$kt1]}\\
& = \frac{[$at]}{e^{[$ktn]}}\\
& = [$ans2]
\end{aligned}``]

END_PGML_SOLUTION

ENDDOCUMENT();
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by Davide Cervone -
It looks like the same problem as your earlier one.

If you use File Manager to move the problem file after it has been added to a homework set, you will get this error. It has nothing to do with the image, only with the fact that you have move the problem from where it was when you added it to the homework set.

The error message:
WeBWorK::Utils::readFile(/opt/webwork/courses/2015_PREP_Problem_Authoring/templates/local/Payer-Homework1/Hoffman_H19_65b.pg) says: failed to read file /opt/webwork/courses/2015_PREP_Problem_Authoring/templates/local/Payer-Homework1/Hoffman_H19_65b.pg: No such file or directory
Is telling you that the .pg file can't be found (because you moved it). Note that the path is
templates/local/Payer-Homework1/Hoffman_H19_65b.pg
but the file is now at
templates/local/Payer-Homework1/Hoffman_H19_65b/Hoffman_H19_65b.pg
Because the file has been moved, the homework set now doesn't know where it is. You either have to change the path in the homework set using the Homework Sets Editor, or add the problem to the set again using its new location.

Again, you have properly set up the directory, moved the .pg file, and uploaded the .png. All of that is correct. You just need to get it linked to the homework set correctly. That is the only missing step.

In reply to Davide Cervone

Re: Lost entire problem contents after importing image?

by tim Payer -
Hi Davide,

I really appreciate your patience. but i am still not clear on the path from here.


How do i re-establish the link to the original HW set for a problem that has had an image added?

The instructions laid out by Paul in the Week 3 video asked us to move the problem (*.pg) file to a new directory from I assume a homework set where it already exists, but then you are telling me that moving the file the source of my problem? Doesn't the problem have to exist in a homework set and then have to be moved to enable the image to couple with the *.pg file?  

Or  do you mean that I moved the file before the image attachment was attempted?

And yes i see that the path of the two files are different.

But I thought this difference was by "design" that this is how the file and image are combined?

Or does this mean that the problem needs to be free of a homework set before we move it to a directory where it can be coupled with an image?

Thanks for your efforts I am really wanting to get this basic point.

I know it is only a 5 minute process, but clearly more for me.

Thanks, Tim
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by Paul Pearson -
Hi Tim,

I have created a short Flash Video of the process used to create two new directories, create a pg file, upload a static image file, and view the result in the Library Browser.  You may need to view this video on a computer that supports flash in a web browser.  The video was too large to upload to the forum, so I put a link to it in the pg problem that I wrote.  To access the video, log in to the 2015 PREP Problem Authoring course and choose problem 1 from the homework set "Embed an image into a webwork problem":

https://testcourses.webwork.maa.org/webwork2/2015_PREP_Problem_Authoring/Embed_an_image_into_a_webwork_problem/1/

In the text of problem 1 there is now a link to the video titled "Link to video that shows how to embed a static image into a webwork problem."  Click the link, watch the video, and let us know if you still have problems.

Best regards,

Paul Pearson
In reply to Paul Pearson

Re: Lost entire problem contents after importing image?

by tim Payer -
Thank you Paul!

That seemed to work. I was not getting the point about an entirely separate directory from the 3rd week video and was convinced on a wrongful path that i had to move the original problem to the new sub-directory.

Could i ask you a few question about this process now that i have a clearer idea?

1.)  Does each problem that I want to hold an image for need its own unique sub-directory? Or could I possibly name a sub-directory "problem-image-pairs" and then have say 12 to 20 problems within this main sub-directory as long as each of them had their own unique sub-directories that held *.pg and *.png pairs.  Or if it came to it only one *.pg problem file per sub-directory that could have two or three image files as long as the code was specified within the problem for those images?

2.)  Is there something that I am missing in the "tex_size=>200" portion of the image statement? Changing the size seems to have no effect and so i am assuming that the default is for 1000 as it is taking up a very large portion of the screen.

I have reduced the size to 400 and then to 40 without any change in size.

I have pasted the code below if you think you can detect my glitch?

Thank you so much for going the extra mile with the flash video. It really helped!

Tim

# Webwork Workshop 2015  for Payer, Homework 1, Problem 2:
# Given the coordinates for the critical point of a general function the student
# should be able to determine the constants of the parameters for the 
# function. Then evaluate the function for a specified input.

 
DOCUMENT();
loadMacros("PGstandard.pl",
           "MathObjects.pl",
  "PGML.pl");
loadMacros("contextFraction.pl");

Context("Numeric");
Context("Fraction");
$m = list_random(3,6,10,12,15,20,30);
$d = Real(random(2,10,1));
$t1 = Real(random(1,3,1));
$h = 60;
($mr,$hr) = reduce($m,$h);
$frac =Compute("$m/$h");
$k1 = Compute("$h/$m");
$a = Compute("$k1*$d");
$a1 = Compute("$k1*$d*e");
$at = Compute("$a*$t1");
$kt = Compute("$k1*$t1");
$kt1 = Compute("1-$kt");
$ktn = Compute("$kt-1");
$ans2 = Compute("$at/(e**($ktn))");
Context()->variables->add(A=>"Real");
Context()->variables->add(k=>"Real");
Context()->variables->add(t=>"Real");

TEXT(beginproblem());
BEGIN_PGML
>> [@ image("Intravenous.png", width=>694, height=>657, tex_size=>40) @]* An intravenous drug injection.<<
The concentration of a particular drug within the bloodstream can be determined by the function: [``C(t) = Ate^{-kt}``], where t is the number of hours since the drug was ingested orally and [`C(t)`] is the concentration of the drug in micrograms per ml of blood. Given that [`A`] and [`k`] are both positive constants.

1.  Given that the maximum concentration of [$d] occurs [$m] minutes after ingesting the drug, find the value of [`A`] and [`k`].
 
    [`k`] = [_____]{("60/[$m]")}
    [`A`] = [_____]{("60*[$d]*e/[$m]")}

2.  What is concentration of the drug in the bloodstream [$t1] hours after its ingestion?

    [`C([$t1])`] = [________]{Compute("(60*[$d]*[$t1]*e**{1-60*[$t1]/[$m]})/[$m]")}

END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*

1.  The maximum concentration of the drug will occur at a critical point because the drug must increase from zero at ingestion and reach a peak value and then gradually dissipate as the body breaks it down. Then the given information yields 
two equations both of which can be used to solve for [`k`] and [`A`]. The two equations 
are: [`C(\text{c.p.}) = [$d]`], and [`C'(\text{c.p.}) = 0`], where c.p. = critical point. Recognize that the 
time in minutes at the maximum concentration must be converted into hours: So t = [$m] minutes = [``\frac{[$m]}{60} = [$frac]``] hours. Then we will use 
C[``\left([$frac]\right) = [$d]``] and [``C'\left([$frac]\right) = 0``] to solve for the 
constants of [`k`] and [`A`].

    *  First apply the prime tics for the product rule and chain rule.  
[``C'(t) = A(t'e^{-kt} + t(e^{-kt})'(-kt)')``] 
    *  Take the derivative.  
[``C'(t) = A(e^{-kt} -kte^{-kt})``] 
    *  Pull the common factor of [``e^{-kt}``] and reduce.  
[``C'(t) = Ae^{-kt}(1 -kt)``]
    *  Input [`t = [$frac]`] into the derivative and set to zero to solve for [`k`].  
[``C'\left([$frac]\right) = Ae^{-[$frac]k}(1 -[$frac]k) = 0``]
    *  Recognize that [`A`] and [``e^{-[$frac]k}``] can not be zero as both are positive.  
[``\begin{aligned}
1 -[$frac]k &= 0 \\     
    [$frac]k &= 1 \\
              k &= \frac{1}{[$frac]}\\
              k &=[$k1]
\end{aligned}``]
    *  We can now substitute [`k = [$k1]`] into the general equation of [``C(t) = Ate^{-kt}``] and use [``C\left([$frac]\right) = [$d]``] to solve for [`A`].  
[``\begin{aligned}
 C\left([$frac]\right) &= A([$frac])e^{-3\left([$frac]\right)} = [$d]\\
     A([$frac])e^{-1} &= [$d]\\
     \frac{A}{[$k1]e} &= [$d]\\
                          A &= [$a]e \\
                          A &= [$a1]
\end{aligned}``]
    *  Substituting both [`k = [$k1]`] and [`A = [$a]e`] values into the general equation yields the specific equation for the blood concentration:  
[``\begin{aligned}
C(t) &= Ate^{-kt}\\
&= [$a]ete^{-[$k1]t}
\end{aligned}``]

    * Combine the common base of e using the rule of exponents to reduce:  
[``C(t) = [$a]te^{1-[$k1]t}``]

2.  Evaluate [``C(t)``] at [``t = [$t1]``] hours to determine the concentration of the drug in the blood stream. We use the reduced form:  
[``\begin{aligned} &\\
C([$t1]) &= [$a]([$t1])e^{1-[$k1]([$t1])}\\
& = [$at]e^{1-[$kt]}\\
& = [$at]e^{[$kt1]}\\
& = \frac{[$at]}{e^{[$ktn]}}\\
& = [$ans2]
\end{aligned}``]

END_PGML_SOLUTION

ENDDOCUMENT();
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by Paul Pearson -
Hi Tim,

There are three reasons to have a single pg file and all its associated image files together in one subdirectory (which has the same name as the basename of the pg file):
  • for organization: so that the pg file and its associated images stay bundled together in an orderly way
  • for maintenance: so that the image files do not get separated from their pg file
  • for automatic features implemented in the Library Browser: the creators of webwork designed it so that when webwork searches a directory (and its subdirectories) for pg files to display in the Library Browser, it will recognize constructs like Problem01/Problem01.pg and treat the directory Problem01/ like a single entity that renders one pg problem rather than a subdirectory that contains multiple pg problems.
When should you put a single pg file and its associated image files together in one directory?  Always.  

Should you put multiple pg files and images together in the same directory?  No, because the Library Browser is not designed to deal with that well and it also makes things disorganized and harder to maintain.  Even when you use the same image files for multiple pg files, you should make a directory for each pg file and put its images in that directory.  (This tiny bit of inefficiency due to storing the same image in multiple directories actually pays dividends when it comes to organization and maintaining problems.)

Webwork delivers homework in two modes: HTML output and pdf hardcopy output (via TeX).  When you change tex_size and view the HTML output, of course you're not seeing the changes because tex_size only affects the pdf hardcopy output.  The value of tex_size scales the image in the pdf hardcopy output, where tex_size is translated to \includegraphics[scale=0.001*tex_size\linewidth]{myimage.png} in the TeX source code.  This means that tex_size=>1000 will make the image in pdf hardcopy mode equal to the value of \linewidth (i.e., the image will fill the entire column width in the pdf hardcopy).  If you have one image of moderate size, reasonable values of tex_size are between 600 and 950.  If you have two images side by side in a table, reasonable values of tex_size are between 350 and 450.

Best regards,

Paul Pearson


In reply to Paul Pearson

Re: Lost entire problem contents after importing image?

by tim Payer -
Hi Paul,

Thank you so much for the detailed answer!

Tim
In reply to tim Payer

Re: Lost entire problem contents after importing image?

by tim Payer -
Hi Paul,

Never mind about the "tex_size" command, i had the wrong dimensions and because of that the default went to 1000.  Sorry for the trouble.

Tim