function CalculateWeight(&$arreglo, &$arregloNormalDate, $fechaExamen, $diasPreparacion, $factorCarga)
 {
     $inicio = strtotime('-' . $diasPreparacion . ' day', strtotime($fechaExamen));
     $inicio = date('Y-m-d', $inicio);
     $i = 1;
     while (strtotime($inicio) < strtotime($fechaExamen)) {
         $miliseconds = strtotime($inicio);
         //$miliseconds=strtotime($inicio)*1; Esto funciona en windows!!!
         $valor = MathFunction::calculate($i, $factorCarga, $diasPreparacion);
         $i++;
         $arregloNormalDate[$inicio] = isset($arregloNormalDate[$inicio]) ? $arregloNormalDate[$inicio] + $valor : $valor;
         $arreglo[$miliseconds] = isset($arreglo[$miliseconds]) ? $arreglo[$miliseconds] + $valor : $valor;
         $inicio = date("Y-m-d", strtotime("+1 day", strtotime($inicio)));
     }
     $miliseconds = strtotime($inicio);
     //$miliseconds=strtotime($inicio)*1; Esto funciona en windows!!!
     $arreglo[$miliseconds] = isset($arreglo[$miliseconds]) ? $arreglo[$miliseconds] + $valor : $valor;
     $arregloNormalDate[$inicio] = isset($arregloNormalDate[$inicio]) ? $arregloNormalDate[$inicio] + $valor : $valor;
 }
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 3, -3);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
$function = new MathFunction('cos');
$function->setColor(new DarkGreen());
$function->mark->setType(MARK_SQUARE);
$function->mark->setSize(3);
$plot->add($function, "f(x) = cos(x)", LEGEND_MARK);
$function = new MathFunction('exp');
$function->setColor(new DarkRed());
$function->mark->setType(MARK_SQUARE);
$function->mark->setSize(3);
$function->mark->setFill(new DarkBlue());
$plot->add($function, "f(x) = exp(x)", LEGEND_MARK);
function x2($x)
{
    return -$x * $x + 0.5;
}
$function = new MathFunction('x2');
$function->setColor(new DarkBlue());
$plot->add($function, "f(x) = - x * x + 0.5");
$plot->legend->setPosition(0.9, 0.8);
$plot->legend->setPadding(3, 3, 3, 3, 3);
$graph->add($plot);
$graph->draw();
/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../../MathPlot.class.php";
$graph = new Graph(400, 400);
$graph->setTiming(TRUE);
$plot = new MathPlot(-3, 3, 6, 0);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
$function = new MathFunction('acos', -1, 1);
$function->setColor(new DarkGreen());
$function->mark->setType(MARK_SQUARE);
$function->mark->setSize(4);
$plot->add($function, "f(x) = acos(x)");
$function = new MathFunction('exp');
$function->setColor(new DarkRed());
$function->mark->setType(MARK_CIRCLE);
$function->mark->setSize(7);
$function->mark->setFill(new Blue());
$function->mark->border->show();
$function->mark->border->setColor(new Black());
$function->line->hide(TRUE);
$plot->add($function, "f(x) = exp(x)");
$plot->legend->setPosition(0.4, 0.1);
$graph->add($plot);
$graph->draw();
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
// Set graph title
$graph->title->set('f(x) = x * x');
$graph->title->setBackgroundColor(new White(0));
$graph->title->setPadding(NULL, NULL, 10, 10);
$graph->title->move(0, -10);
$plot = new MathPlot(-3, 3, 10, -2);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
// Defines x²
function x2($x)
{
    return $x * $x;
}
$function = new MathFunction('x2');
$function->setColor(new Orange());
$plot->add($function);
$graph->add($plot);
$graph->draw();
require_once "../../MathPlot.class.php";
$graph = new Graph(400, 400);
$graph->setTiming(TRUE);
$plot = new MathPlot(-5, 5, 5, -5);
$plot->grid->hide(FALSE);
$plot->grid->setType(LINE_DOTTED);
$plot->setInterval(mt_rand(1, 10) / 10);
function x2($x)
{
    return $x * $x;
}
function random($x)
{
    return mt_rand(-3, 3);
}
$function = new MathFunction('x2');
$plot->add($function, "f(x) = x * x");
$function = new MathFunction('random');
$function->setColor(new Orange());
$plot->add($function);
$function = new MathFunction('sqrt', 0);
$function->setColor(new DarkBlue());
$function->line->setThickness(3);
$plot->add($function, "f(x) = sqrt(x)");
$function = new MathFunction('sin');
$function->setColor(new DarkGreen());
$function->line->setStyle(LINE_DASHED);
$plot->add($function, "f(x) = sin(x)");
$plot->legend->setPosition(NULL, 0.85);
$graph->add($plot);
$graph->draw();
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 20, -1);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
$plot->yAxis->setLabelInterval(4);
$function = new MathFunction('exp');
$function->setColor(new DarkRed());
$function->mark->setType(MARK_SQUARE);
$function->mark->setSize(3);
$function->mark->setFill(new DarkBlue());
$plot->add($function, "f(x) = exp(x)", LEGEND_MARK);
$plot->legend->setPosition(0.4, 0.2);
$plot->legend->setPadding(3, 3, 3, 3, 3);
$graph->add($plot);
$graph->draw();
<?php

/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 2, -3);
$plot->setInterval(0.05);
$function = new MathFunction('sqrt', 0);
$plot->add($function, "sqrt(x)");
function x2($x)
{
    return -$x * $x;
}
$function = new MathFunction('sin', -2, 2);
$function->setColor(new DarkBlue());
$plot->add($function, "sin(x) (-2 < x < 2)");
$plot->legend->setPosition(0.98, 0.8);
$plot->legend->setTextFont(new Tuffy(8));
$graph->add($plot);
$graph->draw();