include("phpmathpublisher/mathpublisher.php"); // $upper=rand(0, 10); // $lower=rand(-10, 0); // $num=4; //
$text="int{".$lower."}{".$upper."}{"; for($i=0;$i<$num;$i++){ $k=rand(1, 5); // x $p=rand(1, 5); // x $sign=rand(0, 2)==0?0:1; // , 2 $tt=$k>1?$k:""; // $tt.="x"; if($p>1)$tt.="^".$p; if($i==0){ if($sign==1)$text.="({-}".$tt.")"; else $text.=$tt; }else $text.=($sign==1?"-":"+").$tt; if($sign==1)$k=-$k; $answer+=($k*pow($upper, $p+1)/($p+1))-($k*pow($lower, $p+1)/($p+1)); // . } $text.="dx}";
$formula=new expression_math(tableau_expression(trim($text))); $formula->dessine(24); // 24 - $w=imagesx($formula->image)+20; // 10 , $h=imagesy($formula->image)+20; $fi=imagecreatetruecolor($w, $h); imagefill($fi, 0, 0, 0xFFFFFF); imagecopy($fi, $formula->image, 10, 10, 0, 0, $w-20, $h-20);
header("Content-type: image/png"); imagepng($im);
Source: https://habr.com/ru/post/120646/
All Articles