Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $fungsi="pow(x,3)*4*pow(x,2)";
- //$fungsi="pow(x,4)";
- $c=preg_match_all("/(\+|\*|\\|\-)*(\d+\*)*(pow\(.,)(\d+)\)/i", $fungsi, $m);
- $turunan="";
- for($i=0; $i<$c; $i++){
- if($i>0)$z=$m[1][$i];
- else $z="";
- $pangkat=$m[4][$i];
- $turunan.=$z.$m[2][$i].$pangkat."*".$m[3][$i].($pangkat-1).")";
- }
- echo $turunan;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement